lua-users home
lua-l archive

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


Mike Pall <mikelu-1001@mike.de> writes:

> 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

The former is more likely what graphical tools in the Simulink style
would generate from plugging symbols together.

-- 
David Kastrup