<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey,</p>
<p>thanks for the patch!</p>
<p>Sergey</p>
<div class="moz-cite-prefix">On 10/24/25 13:50, Sergey Kaplun wrote:<br>
</div>
<blockquote type="cite"
cite="mid:ea1656a9bf4b7efe7c5da541e94682c6435bd4ed.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">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</pre>
</blockquote>
s/2,/2, /
<blockquote type="cite"
cite="mid:ea1656a9bf4b7efe7c5da541e94682c6435bd4ed.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
+ local j = i
+ for len=1,1000000000 do</pre>
</blockquote>
s/1,/1, /
<blockquote type="cite"
cite="mid:ea1656a9bf4b7efe7c5da541e94682c6435bd4ed.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
+ j = bor(band(shr(j,1), band(j,1)-1), band(shl(j,1)+j+1, bnot(band(j,1)-1)))</pre>
</blockquote>
please add whitespaces, here and below
<blockquote type="cite"
cite="mid:ea1656a9bf4b7efe7c5da541e94682c6435bd4ed.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
+ if cache then
+ local x = cache[j]; if x then j = x+len; break end</pre>
</blockquote>
whitespaces
<blockquote type="cite"
cite="mid:ea1656a9bf4b7efe7c5da541e94682c6435bd4ed.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
+ elseif j == 1 then
+ j = len+1; break</pre>
</blockquote>
s/+/ + /
<blockquote type="cite"
cite="mid:ea1656a9bf4b7efe7c5da541e94682c6435bd4ed.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
+ 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()
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>