<!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:f30a54e4f6ada27b930e9407fc3a0de9332e32e0.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.

The benchmark input is given by redirecting the corresponding
<FASTA_5000000> file generated by the `libs/fasta.lua 5e6`. The output
from the benchmark is redirected to /dev/null. Checks are skipped since
the output is very huge, and it is overkill to store it in the
repository.
---
 perf/LuaJIT-benches/revcomp.lua | 84 +++++++++++++++++++++++----------
 1 file changed, 59 insertions(+), 25 deletions(-)

diff --git a/perf/LuaJIT-benches/revcomp.lua b/perf/LuaJIT-benches/revcomp.lua
index 34fe347b..6e8a7049 100644
--- a/perf/LuaJIT-benches/revcomp.lua
+++ b/perf/LuaJIT-benches/revcomp.lua
@@ -1,3 +1,14 @@
+-- The benchmark to check the performance of hash table lookups by
+-- constant keys, string manipulations, and read/write
+-- operations.
+-- This benchmark reads the line-by-line a redirected FASTA format
+-- file from stdin, which is generated by the <fasta.lua>
+-- benchmark, and writes the id, description, and the
+-- reverse-complement sequence in FASTA format to stdout.
+-- For the details see:
+-- <a class="moz-txt-link-freetext" href="https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/revcomp.html">https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/revcomp.html</a>
+
+local bench = require("bench").new(arg)
 
 local sub = string.sub
 iubc = setmetatable({
@@ -9,29 +20,52 @@ iubc = setmetatable({
 }, { __index = function(t, s)
   local r = t[sub(s, 2)]..t[sub(s, 1, 1)]; t[s] = r; return r end })
 
-local wcode = [=[
-return function(t, n)
-  if n == 1 then return end
-  local iubc, sub, write = iubc, string.sub, io.write
-  local s = table.concat(t, "", 1, n-1)
-  for i=#s-59,1,-60 do
-    write(]=]
-for i=59,3,-4 do wcode = wcode.."iubc[sub(s, i+"..(i-3)..", i+"..i..")], " end
-wcode = wcode..[=["\n")
-  end
-  local r = #s % 60
-  if r ~= 0 then
-    for i=r,1,-4 do write(iubc[sub(s, i-3 < 1 and 1 or i-3, i)]) end
-    write("\n")
-  end
-end
-]=]
-local writerev = loadstring(wcode)()
+local stdout = io.output()
+
+bench:add({
+  name = "revcomp",
+  -- The compare with the result output file is inconvenient.
+  skip_check = true,
+  setup = function()
+    io.output("/dev/null")
+  end,
+  payload = function()
+    local wcode = [=[
+    return function(t, n)
+      if n == 1 then return end
+      local iubc, sub, write = iubc, string.sub, io.write
+      local s = table.concat(t, "", 1, n - 1)
+      for i = #s - 59, 1, -60 do
+        write(]=]
+    for i = 59, 3, -4 do
+      wcode = wcode.."iubc[sub(s, i + "..(i - 3)..", i + "..i..")], "
+    end
+    wcode = wcode..[=["\n")
+      end
+      local r = #s % 60
+      if r ~= 0 then
+        for i = r, 1, -4 do write(iubc[sub(s, i - 3 < 1 and 1 or i - 3, i)]) end
+        write("\n")
+      end
+    end
+    ]=]</pre>
    </blockquote>
    <p>could you also apply the patch below with formatting?</p>
    <p>diff --git a/perf/LuaJIT-benches/revcomp.lua
      b/perf/LuaJIT-benches/revcomp.lua<br>
      index 6e8a7049..9050110e 100644<br>
      --- a/perf/LuaJIT-benches/revcomp.lua<br>
      +++ b/perf/LuaJIT-benches/revcomp.lua<br>
      @@ -38,9 +38,9 @@ <a class="moz-txt-link-freetext" href="bench:add(">bench:add(</a>{<br>
             for i = #s - 59, 1, -60 do<br>
               write(]=]<br>
           for i = 59, 3, -4 do<br>
      -      wcode = wcode.."iubc[sub(s, i + "..(i - 3)..", i +
      "..i..")], "<br>
      +      wcode = wcode .. "iubc[sub(s, i + " .. (i - 3) .. ", i + "
      .. i .. ")], "<br>
           end<br>
      -    wcode = wcode..[=["\n")<br>
      +    wcode = wcode .. [=["\n")<br>
             end<br>
             local r = #s % 60<br>
             if r ~= 0 then<br>
      @@ -54,7 +54,10 @@ <a class="moz-txt-link-freetext" href="bench:add(">bench:add(</a>{<br>
           local t, n = {}, 1<br>
           for line in io.lines() do<br>
             local c = sub(line, 1, 1)<br>
      -      if c == ">" then writerev(t, n); io.write(line, "\n"); n
      = 1<br>
      +      if c == ">" then<br>
      +        writerev(t, n);<br>
      +        io.write(line, "\n");<br>
      +        n = 1<br>
             elseif c ~= ";" then t[n] = line; n = n + 1 end<br>
           end<br>
           writerev(t, n)<br>
      <br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
cite="mid:f30a54e4f6ada27b930e9407fc3a0de9332e32e0.1766738771.git.skaplun@tarantool.org">
      <pre wrap="" class="moz-quote-pre">
+    local writerev = loadstring(wcode)()
+
+    local t, n = {}, 1
+    for line in io.lines() do
+      local c = sub(line, 1, 1)
+      if c == ">" then writerev(t, n); io.write(line, "\n"); n = 1
+      elseif c ~= ";" then t[n] = line; n = n + 1 end
+    end
+    writerev(t, n)
+    -- Repeat operation several times.
+    <a class="moz-txt-link-freetext" href="io.stdin:seek(">io.stdin:seek(</a>"set", 0)
+  end,
+  teardown = function()
+    io.output(stdout)
+  end,
+  -- Amount of symbols in the input file.
+  items = 5e6,
+})
 
-local t, n = {}, 1
-for line in io.lines() do
-  local c = sub(line, 1, 1)
-  if c == ">" then writerev(t, n); io.write(line, "\n"); n = 1
-  elseif c ~= ";" then t[n] = line; n = n + 1 end
-end
-writerev(t, n)
+bench:run_and_report()
</pre>
    </blockquote>
  </body>
  <lt-container></lt-container>
</html>