Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

javascript vs lua

Name: Anonymous 2012-01-24 20:47

let's say i might be working on something ``secret'' and i want to embed a scripting language that isn't too off the wall for end users. i hear luajit is kinda fast and v8 is really fast and speed would be quite nice since user scripts might be called hundreds of thousands of times in short timeframes

i've heard javascript has better semantics and is generally more pleasant to use, but i want /prog/'s opinion so i don't fuck up and regret it later

Name: Anonymous 2012-02-14 18:55

>>9

Right... and:

$ cat > time.lua
function analyze(s)
    local start = os.clock()
    local f = loadstring(s)
    for i = 1, 100000 do
        f()
    end
    print(os.clock() - start, "s")
end
for expr in io.lines() do
    analyze(expr)
end

$ luajit2 time.lua
math.sqrt(math.random(1000))
0    s

Multiplying loop counter by 1000 (for i = 1, 100000000 do)

$ luajit2 time.lua
math.sqrt(math.random(1000))
0.57    s

Seems like the Lua version runs in just 0.00057s...

The benchmark is pretty meaningless. It's mostly stressing parser and math.random implementation.

For math.random(), LuaJIT uses Tausworthe PRNG with period of 2^223.

V8 uses much lower quality PRNG; two 16-bit MWCs combined together. this should yield period of about 2^61, give or take.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List