<!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! LGTM</p>
    <p>Sergey</p>
    <div class="moz-cite-prefix">On 12/26/25 12:17, Sergey Kaplun wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:1fa15638dd1db8690aa5f91cc80d9331f54c842f.1766738771.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/fannkuch.lua | 44 +++++++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 3 deletions(-)

diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua
index 2a4cd426..f51e0eaf 100644
--- a/perf/LuaJIT-benches/fannkuch.lua
+++ b/perf/LuaJIT-benches/fannkuch.lua
@@ -1,3 +1,11 @@
+-- The benchmark that checks the performance of operations on
+-- small integers and vectors of integers and the performance of
+-- inner loops of the benchmark. The benchmark finds the maximum
+-- number of flips in the table needed for any permutation.
+-- For the details see:
+-- <a class="moz-txt-link-freetext" href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/fannkuchredux.html">https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/fannkuchredux.html</a>
+
+local bench = require("bench").new(arg)
 
 local function fannkuch(n)
   local p, q, s, odd, check, maxflips = {}, {}, {}, true, 0, 0
@@ -6,7 +14,6 @@ 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")
       check = check + 1
     end
     -- Copy and flip.
@@ -46,5 +53,36 @@ 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 "Performing Lisp Analysis of the
+-- FANNKUCH Benchmark":
+-- <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>