Thats actually difficult, eg Lua has coroutines, a function can be a hash table key and other incompatibilities. There are some but they are fairly limited by this. This is the main implementation https://github.com/mherkender/lua.js
Would be interesting to compare performance to the other ways of getting Lua to run in the browser, which include writing a Lua bytecode interpreter in JS, converting Lua to JS, and code generation from bytecode.
Without any frame of reference, those values are meaningless.
However there is one I can evaluate:
>1.58 MFLOPS
Given I have an i7-2600 and its flops on benchmarks[1] (FPU Flops score: 8500.09 MFlops), that tells me something I could have guessed: performance is 3 orders of magnitude worse than native high performing code.
Still, in order for this comparison to be complete, I'll have to
- try this benchmark in Firefox with OdinMonkey, the new and very promising JS engine[2]
- run a similar benchmark with "native" LUA
edit: results obtained on W7 SP1 with 16GO RAM and Chrome 27.
~> lua scimark.lua
FFT 14.65 [1024]
SOR 30.41 [100]
MC 9.32
SPARSE 19.32 [1000, 5000]
LU 23.70 [100]
SciMark 19.48 [small problem sizes]
~> time lua binarytrees.lua 14.72
stretch tree of depth 15 check: -1
53974 trees of depth 4 check: -53974
13493 trees of depth 6 check: -13492
3373 trees of depth 8 check: -3372
843 trees of depth 10 check: -842
210 trees of depth 12 check: -210
52 trees of depth 14 check: -52
long lived tree of depth 14 check: -1
lua binarytrees.lua 14.72 5,99s user 0,01s system 99% cpu 6,001 total
Edit 2: The same set of benchmarks gives the following results on a ThinkPad X61s laptop with a Core 2 Duo L7500 CPU and 4 GB RAM running Linux Mint 13 Maya, kernel version 3.5.0-32-generic x86_64:
~> lua scimark.lua
FFT 6.55 [1024]
SOR 15.36 [100]
MC 4.11
SPARSE 10.24 [1000, 5000]
LU 12.40 [100]
SciMark 8.73 [small problem sizes]
~> time lua binarytrees.lua 14.72
stretch tree of depth 15 check: -1
53974 trees of depth 4 check: -53974
13493 trees of depth 6 check: -13492
3373 trees of depth 8 check: -3372
843 trees of depth 10 check: -842
210 trees of depth 12 check: -210
52 trees of depth 14 check: -52
long lived tree of depth 14 check: -1
lua binarytrees.lua 14.72 9,63s user 0,04s system 99% cpu 9,713 total
> Without any frame of reference, those values are meaningless.
The page explains how to run them natively as well.
> performance is 3 orders of magnitude worse than native high performing code.
Performance depends on the browser, which did you test on (there are some notes about that on the page)? Also, you can't just compare FLOPS in one test to a theoretical maximal FLOPS on your CPU (or another test), since it depends on the code being run.
This is going to be tracked in realtime here, including a comparison to native,
17 comments
[ 2.8 ms ] story [ 51.1 ms ] thread[1]: http://kripken.github.io/lua.vm.js/repl.html [2]: http://repl.it/
https://github.com/creationix/brozula https://github.com/mherkender/lua.js (and others, I had a list somewhere)
Quite a few companies are using Lua->JS as a way of doing write once run cross platform games eg we had this talk at London Lua http://www.londonlua.org/luajavascript/index.html
>binarytrees 46.051 seconds
Without any frame of reference, those values are meaningless.
However there is one I can evaluate:
>1.58 MFLOPS
Given I have an i7-2600 and its flops on benchmarks[1] (FPU Flops score: 8500.09 MFlops), that tells me something I could have guessed: performance is 3 orders of magnitude worse than native high performing code.
Still, in order for this comparison to be complete, I'll have to
- try this benchmark in Firefox with OdinMonkey, the new and very promising JS engine[2]
- run a similar benchmark with "native" LUA
edit: results obtained on W7 SP1 with 16GO RAM and Chrome 27.
1: http://www.maxxpi.net/results/show.php?ID=c3x2c5w6d7b7
2: did you know the logo was awesome? https://wiki.mozilla.org/File:Odinmonkey800.jpg
http://monkeyink.com/ink/blog/archives/2011/01/jagermonkey_i... http://monkeyink.com/ink/blog/archives/2012/02/its_ion_monke...
How about we compile some results right here?
Below is what I get on an AMD Phenom II X4 965 PC with 8 GB RAM running Linux Mint 13 Maya, kernel version 3.2.0-48-generic x86_64.
— Lua.vm.js in Firefox 21.0
— Native Lua 5.2.2 — Geekbench-2.4.3-Linux on the same computerhttp://browser.primatelabs.com/geekbench2/2076712 (the page includes detailed PC specifications)
Edit: redid the native benchmarks with Lua 5.2.2.
-----
Edit 2: The same set of benchmarks gives the following results on a ThinkPad X61s laptop with a Core 2 Duo L7500 CPU and 4 GB RAM running Linux Mint 13 Maya, kernel version 3.5.0-32-generic x86_64:
— Lua.vm.js in Firefox 21.0
— Native Lua 5.2.2 — Geekbench-2.4.3-Linuxhttp://browser.primatelabs.com/geekbench2/2077111
The page explains how to run them natively as well.
> performance is 3 orders of magnitude worse than native high performing code.
Performance depends on the browser, which did you test on (there are some notes about that on the page)? Also, you can't just compare FLOPS in one test to a theoretical maximal FLOPS on your CPU (or another test), since it depends on the code being run.
This is going to be tracked in realtime here, including a comparison to native,
http://arewefastyet.com/#machine=11&view=breakdown&suite=asm...
(but so far it hasn't shown results for that test yet, just an empty slot, hopefully later today though).
And as you say without other results at the page to compare I'm not sure how bad or good this is.