lua-users home
lua-l archive

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


Ross Bencina <rossb-lists@audiomulch.com> writes:
>> Below I attached to small programs simply calculating sine tables,
>> one Lua version and one in C with - as far as I can see - the exact
>> same implementation.
>
> The obvious difference is the print() function vs. printf(). I would
> expect these to be the most expensive lines of code seems plausible
> that you could see that kind of difference if the flushing behavior
> to stdout was different for example.

I get the following timings:

   $ sh /tmp/s
   Lua 5.1: 1.29s
   Lua 5.2: 1.43s
   LuaJIT2: 0.03s
   gcc 4.6: 0.01s

using this test script, "/tmp/s":

   /usr/bin/time -f'Lua 5.1: %Us' lua5.1 test.lua > /dev/null
   /usr/bin/time -f'Lua 5.2: %Us' lua5.2 test.lua > /dev/null
   /usr/bin/time -f'LuaJIT2: %Us' luajit-2.0.0-beta8 test.lua > /dev/null
   gcc -o test -O3 test.c
   /usr/bin/time -f'gcc 4.6: %Us' ./test > /dev/null

Maybe, as Ross suggested, the timings were done with output going to
the terminal, so buffering etc were a big factor.

[Even compiled without optimization, the C program is as fast as
LuaJIT for me.]

-Miles

-- 
Next to fried food, the South has suffered most from oratory.
  			-- Walter Hines Page