Hi,

a sample lua script runs twice slower with texlua of TL2017
than with the texlua from TL2016 and bare lua 5.3.3 I also
have on my mac os x 10.9.5

is this expected ?

$ time texlua collatz.lua 1 1000000
837799

real    0m39.053s
user    0m39.034s
sys     0m0.017s

$ time lua collatz.lua 1 1000000
837799

real    0m17.004s
user    0m16.991s
sys     0m0.006s

(actually I had gotten about 20s initially )

and:

$ time /usr/local/texlive/2016/bin/x86_64-darwin/texlua collatz.lua 1 1000000
837799

real    0m21.292s
user    0m21.271s
sys     0m0.012s

Thus the TL2017 texlua executes about 2x slower than the TL2016 one

I am on mac os x 10.9.5, 

$ cd `dirname $(which texlua)` && pwd -P
/usr/local/texlive/2017/bin/x86_64-darwinlegacy

$ lua -v
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio

I also have a 
$ /usr/local/bin/lua -v
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio

$ which -a lua
/sw/bin/lua
/usr/local/bin/lua

but I guess this is irrelevant to texlua.

This originates in this answer https://tex.stackexchange.com/a/372669/4686
and I copied the code into collatz.lua, for convenience here it is

---- start of lua script
function collatz_count(n, m)
    local function collatz_next(n)
        if ( n % 2 == 0 ) then
            return n / 2
        else
            return 3 * n + 1
        end
    end

    m = m or 1

    if ( n > 1 ) then
        return collatz_count( collatz_next(n), m + 1 )
    else
        return m
    end
end

function collatz_max_range(start, stop, count, len)
    count = count or 1
    len = len or start
    if start > stop then
        return len
    else
        if collatz_count(start) > count then
            return collatz_max_range(start+1, stop, collatz_count(start), start)
        else
            return collatz_max_range(start+1, stop, count, len)
        end
    end
end

print(collatz_max_range(tonumber(arg[1]),tonumber(arg[2])))

-- code de Henri Menke https://tex.stackexchange.com/a/372669/4686
---- end of lua script


I have observed in other occasions that my mac os x 10.9.5. laptop
has a tendency to have worse performances, in proportion, when
computation times run into the minute or so, compared to some
Linux box I access elsewhere. But here the problem is with comparison
of 2016 and 2017 situations and the fact that bare lua 5.3.3 interpreter
is faster.

Thanks,

Jean-François







Reply via email to