[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luajit vs C performance, unexplainable difference ?
- From: Ico Doornekamp <lua@...>
- Date: Tue, 20 Dec 2011 09:39:24 +0100
* On Tue Dec 20 09:33:26 +0100 2011, Ross Bencina wrote:
> On 20/12/2011 7:23 PM, Ico wrote:
> > 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.
>
> What are your results if you comment these out?
Roughly the same. I left those in because I already tested this and
measured no significant difference with or without printing; I forgot to
mention this in the original mail.
note that if you leave out the printf in the C version and compile with
O3, the compile figures out it can throw away the results and thus skip
the whole calculation. A workaround is to change the return into
return t[1].a;
this will force the compiler to actually do the work.
Thanks,
Ico
--
:wq
^X^Cy^K^X^C^C^C^C