lua-users home
lua-l archive

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


T T wrote:
> > 2011/2/17 T T <t34www@googlemail.com>:
> >> For N=1e8 I get 0.91sec with MATLAB and 0.68sec with LuaJIT-2.  Pretty
> >> close I would say.
> 
> That got me thinking.  Mike, do you do some special optimization for 'a=a+1'?
> I tried with 'a=a+sin(a)' instead and got only 20% difference between
> MATLAB and LuaJIT.

Any speedup you're measuring is relative to the expensiveness of
the underlying instructions. The example loop is dominated by the
latencies of the respective FP operations. FP adds take 3 cycles
each and sin() takes 40-100 cycles.

The latter obviously dominates the total time, so MATLAB's
overhead is less pronounced on the sin() loop. In fact I'd expect
it to take roughly the same time as LuaJIT there, but apparently
MATLAB's compiler is ... errm ... 'suboptimal'.

--Mike