lua-users home
lua-l archive

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


> It's possible, but the standard method of speeding up code is to profile it
> to find the routines that take up the most amount of time.  I haven't done
> this yet for Lua, but I suspect that the total time spent in the virtual
> machine isn't all that great-- as a percentage of the total execution time.

I did it. The profile for Lua depends a lot of the kind of program you
are running. Of course, for tests like «for i=1,100000 do a=a+1 end» most
of the time is spent in the virtual machine. But for more "real" programs
(such as life.lua), `luaV_execute' gets ~20% of the time, hash indexing
(luaH_get and relatives) gets other 20%, and the other 60% goes to many
small tasks, each taking less then 5% (string manipulation, garbage
collection, library calls, etc.). As Passaniti said, some programs can
spend most of this 60% in a few particular library functions (mainly
gsub, strfind, and I/O).

-- Roberto