lua-users home
lua-l archive

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

lua[L]_load[string|file] is one of the most expensive operations you
can perform in Lua. I assume the script itself is not changing 200
times per second, so the probable best solution is to call
lua_loadstring once, and then instead of immediately executing the
function, store it somewhere in the registry or the stack. Then in
future, instead of re-loading the script, simply grab a copy of it
already loaded from where you just put it.

On Thu, Jan 8, 2009 at 6:01 PM, Raymond Jacobs <> wrote:
> Greetings all,
> I am running a trivial script, about 200 times per second and I am seeing
> some significant slow-down from it.
> The script is run each time via a lua_loadstring into a co-routine; given my
> high frequency use, what kind of benefit
> could I expect to see from pre-compiling the script?  I have read that
> compiled Lua is not compatible across platforms,
> so I imagine I would have to do this on first use, and cache it for later?
> rather than precompiling everything up front into files.
> Also, i am planning on writing a Lua function to process, oh 10,000 objects
> (a table of 10,000 objects); i imagine that Lua's speed would be enough to
> do basic arithmetic and such on these objects; but I am more concerned on
> the need to 'box' and 'unbox' these 10,000 objects from C into a table, and
> then
> back again; does anyone have experience with this?
> Thanks for any information you can provide :)
> Raymond Jacobs
> Owner,
> Ethereal Darkness Interactive