[Tarantool-patches] [PATCH v1 luajit 08/41] perf: adjust euler14-bit in LuaJIT-benches

Sergey Bronnikov sergeyb at tarantool.org
Thu Nov 13 14:44:12 MSK 2025


Hi, Sergey,

thanks for the patch!

Sergey

On 10/24/25 13:50, Sergey Kaplun wrote:
> This patch adjusts the aforementioned test to use the benchmark
> framework introduced before. The default arguments are adjusted
> according to the <PARAM_x86.txt> file. The arguments to the script still
> can be provided in the command line run.
> ---
>   perf/LuaJIT-benches/euler14-bit.lua | 52 ++++++++++++++++++++---------
>   1 file changed, 36 insertions(+), 16 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/euler14-bit.lua b/perf/LuaJIT-benches/euler14-bit.lua
> index 537f2bf3..7c521deb 100644
> --- a/perf/LuaJIT-benches/euler14-bit.lua
> +++ b/perf/LuaJIT-benches/euler14-bit.lua
> @@ -1,22 +1,42 @@
> +local bench = require("bench").new(arg)
>   
>   local bit = require("bit")
>   local bnot, bor, band = bit.bnot, bit.bor, bit.band
>   local shl, shr = bit.lshift, bit.rshift
>   
> -local N = tonumber(arg and arg[1]) or 10000000
> -local cache, m, n = { 1 }, 1, 1
> -if arg and arg[2] then cache = nil end
> -for i=2,N do
> -  local j = i
> -  for len=1,1000000000 do
> -    j = bor(band(shr(j,1), band(j,1)-1), band(shl(j,1)+j+1, bnot(band(j,1)-1)))
> -    if cache then
> -      local x = cache[j]; if x then j = x+len; break end
> -    elseif j == 1 then
> -      j = len+1; break
> +local DEFAULT_N = 2e7
> +local N = tonumber(arg and arg[1]) or DEFAULT_N
> +local drop_cache = arg and arg[2]
> +
> +bench:add({
> +  name = "euler14_bit",
> +  payload = function()
> +    local cache, m, n = { 1 }, 1, 1
> +    if drop_cache then cache = nil end
> +    for i=2,N do
s/2,/2, /
> +      local j = i
> +      for len=1,1000000000 do
s/1,/1, /
> +        j = bor(band(shr(j,1), band(j,1)-1), band(shl(j,1)+j+1, bnot(band(j,1)-1)))
please add whitespaces, here and below
> +        if cache then
> +          local x = cache[j]; if x then j = x+len; break end
whitespaces
> +        elseif j == 1 then
> +          j = len+1; break
s/+/ + /
> +        end
> +      end
> +      if cache then cache[i] = j end
> +      if j > m then m, n = j, i end
> +    end
> +    return {n = n, m = m}
> +  end,
> +  checker = function(res)
> +    if N ~= DEFAULT_N then
> +      -- Test only for the default.
> +      return true
> +    else
> +      return res.n == 18064027 and res.m == 623
>       end
> -  end
> -  if cache then cache[i] = j end
> -  if j > m then m, n = j, i end
> -end
> -io.write("Found ", n, " (chain length: ", m, ")\n")
> +  end,
> +  items = N,
> +})
> +
> +bench:run_and_report()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20251113/373823e7/attachment.htm>


More information about the Tarantool-patches mailing list