lua-users home
lua-l archive

Re: can someone explain why...

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>> Le 5 oct. 2010 à 14:27, Michal Kolodziejczyk a écrit :
> It is part of Lua Programming Gems:
> http://www.lua.org/gems/
Thanks.
By the way, I've just received the Programming in Lua 2nd edition.
Very good book.
Ok, my next neuronal-challenge as a Lua-learner :)
I have this simple script :
function m( x0, radius) -- radius : ~ 2 to 7
 local t = {}
 local N = 0
 for x = x0-radius, x0+radius do
 t[N] = get_val( x )
 N = N + 1
 end
 table.sort( t )
 .....
end
To speed it up a bit, I did replace :
 local t = {}
by
 local t = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
I gain around 20%.
Can you comment or give me better ways to optimize this kind of scripts
please, spare me writing this in C :)
it is called million of times, the whole process can be around 30 to 100 seconds
Regards,
Thierry

AltStyle によって変換されたページ (->オリジナル) /