|
Mike Pall wrote:
Here's the timing on a code snippet which alternates between two opcodes (LOADBOOL and FORLOOP): $ TIMEFORMAT="%U" $ time lua -e 'local x; for i=1,1e8 do x = true end' 6.106 $ time luajit -e 'local x; for i=1,1e8 do x = true end' 0.893
Superior! Both your project and your knowledge!But it could be faster. I experimented with compiling Lua to C few month ago.(I planned and still planning to move to asm) My recipe was: `unwind' VM-switch into linear program with gotos, and do some high level optimization based on my so-called soft-types-system and good thinking.
For example: if the step, limit and start of for are integers why then we use floating point arithmetic? If register where i-variable is stored is not used in for-body at all, then why we waste time boxing value it in the stackobject? Etc...
In my approach I trade dynamism and memory for speed. Ad majorem Lua gloriam, Antero Vipunen.