[Tarantool-patches] [PATCH v1 luajit 11/41] perf: adjust k-nucleotide in LuaJIT-benches
Sergey Kaplun
skaplun at tarantool.org
Fri Dec 26 11:17:34 MSK 2025
Hi, Sergey!
Thanks for the review!
Fixed your comments and added the benchmark description.
On 17.11.25, Sergey Bronnikov wrote:
> Hi, Sergey,
>
> thanks for the patch!
>
> Sergey
>
> On 10/24/25 13:50, Sergey Kaplun wrote:
> > 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. All checks are done by
> > the comparison with the precomputed values for the aforementioned file.
> > ---
> > perf/LuaJIT-benches/k-nucleotide.lua | 93 ++++++++++++++++++++++++----
> > 1 file changed, 82 insertions(+), 11 deletions(-)
> >
> > diff --git a/perf/LuaJIT-benches/k-nucleotide.lua b/perf/LuaJIT-benches/k-nucleotide.lua
> > index 0bfb41be..ae51dae9 100644
> > --- a/perf/LuaJIT-benches/k-nucleotide.lua
> > +++ b/perf/LuaJIT-benches/k-nucleotide.lua
> > @@ -1,3 +1,4 @@
Also, added the comment with the benchmark description as we discussed
offline:
===================================================================
diff --git a/perf/LuaJIT-benches/k-nucleotide.lua b/perf/LuaJIT-benches/k-nucleotide.lua
index 2a6cbb67..e92429e8 100644
--- a/perf/LuaJIT-benches/k-nucleotide.lua
+++ b/perf/LuaJIT-benches/k-nucleotide.lua
@@ -1,3 +1,9 @@
+-- The benchmark that checks the performance of hash tables.
+-- The program reads the redirected FASTA format file from stdin,
+-- extracts DNA sequence THREE, and counts the specific sequences.
+-- For the details see:
+-- https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/knucleotide.html
+
local bench = require('bench').new(arg)
local function kfrequency(seq, freq, k, frame)
===================================================================
> > +local bench = require('bench').new(arg)
> >
> > local function kfrequency(seq, freq, k, frame)
> > local sub = string.sub
> > @@ -12,7 +13,8 @@ local function count(seq, frag)
> > local k = #frag
> > local freq = {}
> > for frame=1,k do kfrequency(seq, freq, k, frame) end
> > - io.write(freq[frag] or 0, "\t", frag, "\n")
> > + return freq[frag]
> > + -- io.write(freq[frag] or 0, "\t", frag, "\n")
> remove this at all?
> > end
> >
> > local function frequency(seq, k)
> > @@ -24,10 +26,13 @@ local function frequency(seq, k)
> > local fa, fb = freq[a], freq[b]
> > return fa == fb and a > b or fa > fb
> > end)
> > + local res = {}
> > for _,c in ipairs(sfreq) do
> > - io.write(string.format("%s %0.3f\n", c, (freq[c]*100)/sum))
> > + -- io.write(string.format("%s %0.3f\n", c, (freq[c]*100)/sum))
> remove?
> > + res[c] = freq[c]*100/sum
> > end
> > - io.write("\n")
> > + -- io.write("\n")
> > + return res
> > end
> >
> > local function readseq()
> > @@ -48,11 +53,77 @@ local function readseq()
Removed all output, as you suggested:
===================================================================
diff --git a/perf/LuaJIT-benches/k-nucleotide.lua b/perf/LuaJIT-benches/k-nucleotide.lua
index ae51dae9..2a6cbb67 100644
--- a/perf/LuaJIT-benches/k-nucleotide.lua
+++ b/perf/LuaJIT-benches/k-nucleotide.lua
@@ -14,7 +14,6 @@ local function count(seq, frag)
local freq = {}
for frame=1,k do kfrequency(seq, freq, k, frame) end
return freq[frag]
- -- io.write(freq[frag] or 0, "\t", frag, "\n")
end
local function frequency(seq, k)
@@ -28,10 +27,8 @@ local function frequency(seq, k)
end)
local res = {}
for _,c in ipairs(sfreq) do
- -- io.write(string.format("%s %0.3f\n", c, (freq[c]*100)/sum))
res[c] = freq[c]*100/sum
end
- -- io.write("\n")
return res
end
===================================================================
<snipped>
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list