
Lua.vm.js - iambot
http://kripken.github.io/lua.vm.js/lua.vm.js.html
======
bru
>Score: 130

>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](http://www.maxxpi.net/results/show.php?ID=c3x2c5w6d7b7)

2: did you know the logo was awesome?
[https://wiki.mozilla.org/File:Odinmonkey800.jpg](https://wiki.mozilla.org/File:Odinmonkey800.jpg)

~~~
networked
>Without any frame of reference, those values are meaningless.

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_

    
    
        Score:      115
        binarytrees 56.978 seconds
        scimark     1.79   MFLOPS
        startup     0.431  seconds
    

_— Native Lua 5.2.2_

    
    
        ~> 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
    

_— Geekbench-2.4.3-Linux on the same computer_

[http://browser.primatelabs.com/geekbench2/2076712](http://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_

    
    
        Score:      59
        binarytrees 117.675 seconds
        scimark     0.95    MFLOPS
        startup     0.822   seconds
    

_— Native Lua 5.2.2_

    
    
        ~> 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
    

_— Geekbench-2.4.3-Linux_

[http://browser.primatelabs.com/geekbench2/2077111](http://browser.primatelabs.com/geekbench2/2077111)

------
justincormack
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.

[https://github.com/creationix/brozula](https://github.com/creationix/brozula)
[https://github.com/mherkender/lua.js](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](http://www.londonlua.org/luajavascript/index.html)

~~~
snarfy
Is there an asm.js port of Lua?

~~~
dubcanada
Why would you need an asm.js port of lua? Just use LuaJIT it's already faster
then asm.js. And Lua itself is already faster then Javascript.

------
acron0
I have no immediate use for this but goddamnit, it's cool.

~~~
goldfeld
The immediate use for some might be setting up a tutorial to teach Lua in the
browser[1]. However I wonder how these guys were doing it[2].

[1]:
[http://kripken.github.io/lua.vm.js/repl.html](http://kripken.github.io/lua.vm.js/repl.html)
[2]: [http://repl.it/](http://repl.it/)

------
manuletroll
Does anyone know of a good "compile to js" lua implementation ?

~~~
justincormack
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](https://github.com/mherkender/lua.js)

------
rajahafify
When people blog about don't use default bootstrap template, I often take it
with a grain of salt. Now i'm absolutely positive.

~~~
kyle_wm
what?

~~~
dubcanada
Did you mean use the default bootstrap? I'm confused what you meant.

------
otikik
<3 <3 <3

