[Tarantool-patches] [PATCH v1 luajit 26/41] perf: adjust revcomp in LuaJIT-benches
Sergey Kaplun
skaplun at tarantool.org
Fri Dec 26 11:31:32 MSK 2025
Hi, Sergey!
Thanks for the review!
Fixed your comment and added the short benchmark description as
you suggested.
On 17.11.25, Sergey Bronnikov wrote:
> Hi, Sergey,
>
> thanks for the patch! See my comments.
Discussed offline and fixed your comments.
>
> Sergey
>
> On 10/24/25 13:50, Sergey Kaplun wrote:
<snipped>
> > diff --git a/perf/LuaJIT-benches/revcomp.lua b/perf/LuaJIT-benches/revcomp.lua
> > index 34fe347b..2b1ffa5c 100644
> > --- a/perf/LuaJIT-benches/revcomp.lua
> > +++ b/perf/LuaJIT-benches/revcomp.lua
> > @@ -1,3 +1,4 @@
Added the comment with the short benchmark description, as we
discussed offline:
===================================================================
diff --git a/perf/LuaJIT-benches/revcomp.lua b/perf/LuaJIT-benches/revcomp.lua
index cc944f39..6e8a7049 100644
--- a/perf/LuaJIT-benches/revcomp.lua
+++ b/perf/LuaJIT-benches/revcomp.lua
@@ -1,3 +1,13 @@
+-- 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:
+-- https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/revcomp.html
+
local bench = require("bench").new(arg)
local sub = string.sub
===================================================================
> > +local bench = require("bench").new(arg)
> >
> > local sub = string.sub
> > iubc = setmetatable({
> > @@ -9,29 +10,50 @@ iubc = setmetatable({
<snipped>
> > +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
> > + ]=]
Discussed offline and reformatted as the following:
===================================================================
diff --git a/perf/LuaJIT-benches/revcomp.lua b/perf/LuaJIT-benches/revcomp.lua
index 2b1ffa5c..cc944f39 100644
--- a/perf/LuaJIT-benches/revcomp.lua
+++ b/perf/LuaJIT-benches/revcomp.lua
@@ -24,15 +24,17 @@ bench:add({
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
+ 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
+ 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
+ for i = r, 1, -4 do write(iubc[sub(s, i - 3 < 1 and 1 or i - 3, i)]) end
write("\n")
end
end
===================================================================
<snipped>
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list