<!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:a071e4b569cfe5c1ed72d7f3fd4771c549e3755e.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.
---
I'm not sure that amount of permutations is the correct items count.
Have you any other suggestions?
perf/LuaJIT-benches/fannkuch.lua | 37 +++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua
index 2a4cd426..c963c66f 100644
--- a/perf/LuaJIT-benches/fannkuch.lua
+++ b/perf/LuaJIT-benches/fannkuch.lua</pre>
</blockquote>
<p>I'm highly recommend adding description to benchmarks.</p>
<p>At least to the tests from "benchmarks game" suite.</p>
<p>You can use descriptions from the [1] and [2].</p>
<p>1. <a class="moz-txt-link-freetext" href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/">https://benchmarksgame-team.pages.debian.net/benchmarksgame/</a></p>
<p>2.
<a class="moz-txt-link-freetext" href="https://en.wikipedia.org/wiki/The_Computer_Language_Benchmarks_Game#Benchmark_programs">https://en.wikipedia.org/wiki/The_Computer_Language_Benchmarks_Game#Benchmark_programs</a></p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:a071e4b569cfe5c1ed72d7f3fd4771c549e3755e.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
@@ -1,3 +1,4 @@
+local bench = require("bench").new(arg)
local function fannkuch(n)
local p, q, s, odd, check, maxflips = {}, {}, {}, true, 0, 0
@@ -6,7 +7,7 @@ local function fannkuch(n)
-- Print max. 30 permutations.
if check < 30 then
if not p[n] then return maxflips end -- Catch n = 0, 1, 2.
- io.write(unpack(p)); io.write("\n")
+ -- io.write(unpack(p)); io.write("\n")</pre>
</blockquote>
isn't better to remove at all?
<blockquote type="cite"
cite="mid:a071e4b569cfe5c1ed72d7f3fd4771c549e3755e.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
check = check + 1
end
-- Copy and flip.
@@ -46,5 +47,35 @@ local function fannkuch(n)
until false
end
-local n = tonumber(arg and arg[1]) or 1
-io.write("Pfannkuchen(", n, ") = ", fannkuch(n), "\n")
+local n = tonumber(arg and arg[1]) or 11
+
+-- Precomputed numbers taken from:</pre>
</blockquote>
please add description of the paper as well: "Performing Lisp
Analysis of the FANNKUCH Benchmark"
<blockquote type="cite"
cite="mid:a071e4b569cfe5c1ed72d7f3fd4771c549e3755e.1761301736.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
+-- <a class="moz-txt-link-freetext" href="https://dl.acm.org/doi/pdf/10.1145/382109.382124">https://dl.acm.org/doi/pdf/10.1145/382109.382124</a>
+local FANNKUCH = { 0, 1, 2, 4, 7, 10, 16, 22, 30, 38, 51, 65, 80 }
+
+local function factorial(n)
+ local fact = 1
+ for i = 2, n do
+ fact = fact * i
+ end
+ return fact
+end
+
+bench:add({
+ name = "fannkuch",
+ payload = function()
+ return fannkuch(n)
+ end,
+ checker = function(res)
+ if n > #FANNKUCH then
+ -- Not precomputed, so can't check.
+ return true
+ else
+ return res == FANNKUCH[n]
+ end
+ end,
+ -- Assume that we count permutations here.
+ items = factorial(n),
+})
+
+bench:run_and_report()
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>