From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 5A1B416AFFE8; Fri, 26 Dec 2025 12:23:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5A1B416AFFE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766741032; bh=HVe7BriOUhtPN7OmPBwHzBbDlKebIMSbeHbxw2oOYgI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=TcXFoPMCQrF/RA4oafXLGV+5LXu8m6b3qRHDpKIazjNk2c1PjPAkZ6cSAo6LVCWRd 7vnvvBEcF0FJwbBsiJrA9KtaARVuhecd1amTNjnqhY94l1YWX/u+Y1KDRjGovwwde4 Xfyo9sNxa2BM5JLDdIKVPl9T49xVkgPPDjWaqFR4= Received: from send219.i.mail.ru (send219.i.mail.ru [95.163.59.58]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 892A016C6585 for ; Fri, 26 Dec 2025 12:18:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 892A016C6585 Received: by exim-smtp-7b4fb89df9-lft7n with esmtpa (envelope-from ) id 1vZ3xw-000000008Cp-2JHA; Fri, 26 Dec 2025 12:18:32 +0300 To: Sergey Bronnikov Date: Fri, 26 Dec 2025 12:17:42 +0300 Message-ID: <27c8ab14bd988b3a60f9204502b7e0edb14c7480.1766738771.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD651A111AECFA267DF4E9497E9DD4D3AA182A05F53808504085D0D8C0DBAB6D243DE06ABAFEAF67055AAEC619BD6732F7B4FA2C6BBBE99EF9ACCB5262BB521CA2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72F22E6DC541F75D9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C869676185B4800D87578EDCD39A7D089D1A3C5A590C8D493A43389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C000E2D00546020E658941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6042F1592492B88C6CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE79E9721B410A3B6ED731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5F9111F39C8531B4A5002B1117B3ED696DE7ED7281EAF4FD1B48B7A7F94616420823CB91A9FED034534781492E4B8EEAD3B90412627F530F9A71A35648BE338CE9510FB958DCE06DB58C12E6D310A6D53A16EC4B4EECACEB3 X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659F07855A8B4E28E15FAD134B1A1A6E6831A28927B720A18176B654865A40C24A2685E15D1C938F84CB8341EE9D5BE9A0A4C4EF716EB8EBF4305D8439B09F6DFF0CA1AB629647D117A6536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXbfjcAqQg/jcI= X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD2C67C630E499EAED38700636FE984EBB854A246E2E6553A28E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 11/41] perf: adjust k-nucleotide in LuaJIT-benches X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch adjusts the aforementioned test to use the benchmark framework introduced before. The default arguments are adjusted according to the file. The arguments to the script still can be provided in the command line run. The benchmark input is given by redirecting the corresponding 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 | 96 ++++++++++++++++++++++++---- 1 file changed, 85 insertions(+), 11 deletions(-) diff --git a/perf/LuaJIT-benches/k-nucleotide.lua b/perf/LuaJIT-benches/k-nucleotide.lua index 0bfb41be..e92429e8 100644 --- a/perf/LuaJIT-benches/k-nucleotide.lua +++ b/perf/LuaJIT-benches/k-nucleotide.lua @@ -1,3 +1,10 @@ +-- 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 sub = string.sub @@ -12,7 +19,7 @@ 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] end local function frequency(seq, k) @@ -24,10 +31,11 @@ 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)) + res[c] = freq[c]*100/sum end - io.write("\n") + return res end local function readseq() @@ -48,11 +56,77 @@ local function readseq() return string.upper(table.concat(lines, "", 1, ln)) end -local seq = readseq() -frequency(seq, 1) -frequency(seq, 2) -count(seq, "GGT") -count(seq, "GGTA") -count(seq, "GGTATT") -count(seq, "GGTATTTTAATT") -count(seq, "GGTATTTTAATTTATAGT") +local function check_freq(res, expected) + for k,v in pairs(expected) do + assert(string.format("%0.3f", res[k]) == v, + "Incorrect frequency for fragment " .. k) + end +end + +-- The input is generated by `fasta.lua 5e6'. The check function +-- is corresponding. +local N = 5e6 +-- See for the details. +local items = N * 5 +bench:add({ + name = "k_nucleotide", + payload = function() + local seq = readseq() + local sfreq1 = frequency(seq, 1) + local sfreq2 = frequency(seq, 2) + local GGT = count(seq, "GGT") + local GGTA = count(seq, "GGTA") + local GGTATT = count(seq, "GGTATT") + local GGTATTTTAATT = count(seq, "GGTATTTTAATT") + local GGTATTTTAATTTATAGT = count(seq, "GGTATTTTAATTTATAGT") + + local res = { + sfreq1 = sfreq1, + sfreq2 = sfreq2, + GGT = GGT, + GGTA = GGTA, + GGTATT = GGTATT, + GGTATTTTAATT = GGTATTTTAATT, + GGTATTTTAATTTATAGT = GGTATTTTAATTTATAGT, + } + -- XXX: Reset input for the non-check iteration. + io.stdin:seek("set", 0) + return res + end, + checker = function(res) + check_freq(res.sfreq1, { + A = "30.296", + T = "30.149", + C = "19.800", + G = "19.754", + }) + check_freq(res.sfreq2, { + AA = "9.177", + TA = "9.132", + AT = "9.130", + TT = "9.091", + CA = "6.002", + AC = "6.001", + AG = "5.987", + GA = "5.984", + CT = "5.971", + TC = "5.971", + GT = "5.957", + TG = "5.956", + CC = "3.917", + GC = "3.911", + CG = "3.909", + GG = "3.902", + }) + + assert(res.GGT == 294331) + assert(res.GGTA == 89290) + assert(res.GGTATT == 9462) + assert(res.GGTATTTTAATT == 178) + assert(res.GGTATTTTAATTTATAGT == 178) + return true + end, + items = items, +}) + +bench:run_and_report() -- 2.52.0