lua-users home
lua-l archive

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


Hi!

Playing with Mozilla's SpiderMonkey (FireFox 2.0) I've found that string operations
in js are extremely faster then in Lua. For example this js code snippet

        var str="";
        var cmpStr="vary long number..."
        
        for(i=0; i <= 30000; i++)
        {
           str=str+i;   
           if(str==cmpStr)
           {
           }
        }

is ~20 times faster then Lua code:

       local str=""
       local cmpStr="vary long number..."

       for i=0,30000 do
            str=str..i
            if str==cmpStr then
            end
       end

Here we have number2string conversion, strings concatenation and
strings comparison...

~150 ms in FF2.0
~3000 ms in Lua 5.1.2
~6000 ms in IE6

Is it possible to improve string operations performance in Lua?