lua-users home
lua-l archive

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

Javier Guerra wrote:
> > time target-toy-jit 1000000
> >        real 0.013s
> > time ./toy 1000000
> >        real 0.145s
> >        real 0.068s (when compiled with gcc -O2)
> are you sure that target-toy-jit (whatever that means) is 11x faster
> than C, and 5x faster than gcc -O2?

This is comparing an interpreter for a toy language written in
Python/Lua/C with a meta-compiled version of it with hints for
PyPy. The meta-compiler turns it into non-interpreted code.

Obviously neither the Lua nor the C program has any hints for a
meta-compiler or are run under a meta-compiler. So you'd really
need to compare the results to this loop:

  local x,a=0,1000000; for i=a,1,-1 do x=x+a end; print(x)

LuaJIT happily turns that into the optimal machine code and runs
it in 0.001s on my machine. This *includes* the compile time.
Equivalent C code (summing with doubles) runs in the same time.

In other words: PyPy's meta-compiler is rather slow (it needs ten
minutes (!) for that trivial example) and produces code which is
still at least 5x-10x slower than comparable native code.