Re[2]: strange performance problem
- From: vostrikov <vostrikov@xxxxxxxxxxxx>
- To: luajit@xxxxxxxxxxxxx
- Date: Thu, 02 Jul 2015 10:02:13 +0300
ffi.cdef "complex csqrt(complex);"
M.sqrt = ffi.C.csqrt
Hi.
Rewriting this as
ffi.cdef [[void lj_csqrt(double re, double im, complex *ret);]]
M.sqrt = function (x)
local ret = ffi.new('complex[0]')
t.lj_csqrt2(x.re, x.im, ret)
return ret[0]
end
with trivial csqrt wrapper as
void lj_csqrt2(complex arg, complex *ret) { *ret = csqrt(arg); }
results in more than ten fold speedup.
Other related posts: