lua-users home
lua-l archive

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


On Wed, 14 Nov 2018 at 19:55, Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
>    C:\Software\ravi\bin>type program.lua
>       local function f()
>          local tm = os.clock()
>          local o = 0
>          for j = 1, 1e4 do
>             local x = 0
>             for k = 1, 1e5 do
>                x = x ~ (j + k)
>             end
>             o = o | x
>          end
>          print("   Result = "..o)
>          print("   CPU time = "..(os.clock() - tm))
>       end
>       print"Benchmarking non-compiled function"
>       f()
>       print"Compiling the function"
>       assert(ravi.compile(f))
>       print"Benchmarking compiled function"
>       f()
>

Here are LLVM results on my Windows machine:
C:\work\github\ravi\ravi-tests>ravi egor_test.lua
Benchmarking non-compiled function
   Result = 114656
   CPU time = 11.709
Compiling the function
Benchmarking compiled function
   Result = 114656
   CPU time = 6.633

C:\work\github\ravi\ravi-tests>ravi egor_test_typed.lua
Benchmarking non-compiled function
   Result = 114656
   CPU time = 9.832
Compiling the function
Benchmarking compiled function
   Result = 114656
   CPU time = 0.311

I have uploaded a distribution that uses LLVM backend - please see
https://github.com/dibyendumajumdar/ravi-distro/releases

What you can see from above, and my experience is that, JIT compiling
plain Lua code will make code 2x faster at best; to get big
improvements  type annotations are needed.

Regards
Dibyendu