[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT & iterator sequences (a question for Mike Pall)
- From: Mike Pall <mikelu-1001@...>
- Date: Sun, 3 Jan 2010 13:57:10 +0100
Mark Hamburg wrote:
> The answer seems to be that LuaJIT doesn't like this sort of
> code. Lua 5.1.4 sees a roughly 2.5x slowdown on MacOS X 10.6 for
> the following code but LuaJIT 2.0-beta2 sees an almost 9x
> slowdown. It still beats Lua 5.1.4 by a wide margin (the
> sequence code in LuaJIT runs in about 60% of the open code in
> Lua 5.1.4), but apparently the tracing JIT can't manage to do as
> much with the sequence code as I might have hoped.
The sequence version runs in the interpreter, because calls to
vararg functions are not compiled, yet. The open coded version
runs 33x faster than with Lua.
But do you really seriously think that this:
for v in s.seq( plus_one, 0, 0 )( s.take, limit )( s.filter, is_odd )( s.map, square )( s.iterator ) do
total = total + v
end
is more readable than this:
for i=1,limit do total = total + i*i*(i%2) end
I mean ... apart from the fact that the latter is 80x faster than
the former under LuaJIT. :-)
--Mike