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 F3F5216C6596; Fri, 26 Dec 2025 12:31:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F3F5216C6596 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766741485; bh=ovRjk5ilgCzCMxrNmuPBWA6i15yGGWFV8lzVITHZqOU=; 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=rs8fAAC3QILeByQ8wH5o71aaa4L2TSIpdH4QbngaotixODtbVVa9T/KoJOr3vEnPd ShJqLUyZ1Z2QGzuMJe9hq6CLZRKaUiiE+znDsGnH2f08jwDrzeYNicaDbjXblwUb12 jv9h+9Yq5Nll23EAlXEJBqUxXzaLeiWBbfZCeFzY= Received: from send240.i.mail.ru (send240.i.mail.ru [95.163.59.79]) (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 1330C16C6599 for ; Fri, 26 Dec 2025 12:19:18 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1330C16C6599 Received: by exim-smtp-7b4fb89df9-lft7n with esmtpa (envelope-from ) id 1vZ3yf-000000008Cp-0aDE; Fri, 26 Dec 2025 12:19:17 +0300 To: Sergey Bronnikov Date: Fri, 26 Dec 2025 12:17:57 +0300 Message-ID: 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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD136B1DE29D0A141801E96C80D96E6DBF182A05F53808504020356FC523C73AC33DE06ABAFEAF67058ED98439ACC39341B4FA2C6BBBE99EF911835EED5C149C5A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE701173C01F417A2A6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C869549F07E6F08EE74D8EDCD39A7D089D1AEEA2B0DD7302F4CA389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0EF2A066DDA19BA868941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6042F1592492B88C6CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE778B471BB9634AD8A731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A57E514BEEB13E096C5002B1117B3ED6965FFBD94BBDAFFD70E772F934B9BCD185823CB91A9FED034534781492E4B8EEAD6804EF05EF4ADF2AF36E2E0160E5C55395B8A2A0B6518DF68C46860778A80D548E8926FB43031F38 X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659D462B3344C663C28EEF7AC51DC6A13038A3EE0A69355EAF793A326CA180AEF8DA82414780465E27FB8341EE9D5BE9A0AA3A961B1DCA0227C05D8439B09F6DFF0FAEBB69521F729C86536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXb1PYh6npIAFU= X-DA7885C5: DCC727741C3A4DEBF255D290C0D534F95F4C02A5629B2EF94A923C40A45A65A8B724853401F284E05B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD29759BA4E5E9F40988700636FE984EBB8BD496FE824A9BE72E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 26/41] perf: adjust revcomp 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. 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 +-- 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 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 + ]=] + 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. + io.stdin:seek("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() -- 2.52.0