[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: luajit vs C performance, unexplainable difference ?
- From: Miles Bader <miles@...>
- Date: Tue, 20 Dec 2011 17:47:01 +0900
Ross Bencina <email@example.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
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.]
Next to fried food, the South has suffered most from oratory.
-- Walter Hines Page