lua-users home
lua-l archive

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

* 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.