I ran this test too out of curiosity, and here are my results: (I replaced os.time() with os.clock()) Lua 5.1: 10.769 seconds Lua 5.2: 10.99 seconds LuaJIT 2.0.1: 8.781 seconds LuaJIT 2.1.0-alpha: 21.346 seconds where both LuaJITs are the latest git version. So in my case, LuaJIT 2.0.1 is the fastest. 2013/5/22 Geoff Leyland <geoff_leyland@xxxxxxxxxxx>: > On 23/05/2013, at 7:43 AM, madigest i <madigest@xxxxxxxxxxxxx> wrote: > >> Hello. >> >> I have had strange performance problems with many of my different Lua >> programs that handle big strings. I finally made a small test program to >> demonstrate the problem. >> >> Here are the results in OSX: >> LuaJIT 2.1.0-alpha: 46 seconds >> LuaJIT 2.0.1: 39 seconds >> Lua 5.1: 22 seconds > > LuaJIT 2 doesn't compile string concatenation, and LuaJIT 2.1 doesn't compile > the gmatch. > > I realise this is a test case, not your real code, but why isn't your inner > loop like: > > local codeout = {} > local timeUsed = os.time() > for line in code:gmatch("[^\r\n]+") do > codeout[#codeout+1] = line.."\n" > end > codeout = table.concat(codeout, "") > timeUsed = os.time() - timeUsed > > That takes 0s on all versions. (Use os.clock in preference to os.time, it > has better resolution) > >