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 7C54D15B1F7C; Fri, 24 Oct 2025 13:55:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7C54D15B1F7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1761303315; bh=pN7Zx+wmIAH3I6M0gS2Shov/Rwr0sjXCpO9qj5mvWZ4=; 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=Oeh9kRz6R5oqDgDeTIpMJh4hyQtowGXmfIU/OzBkO0GCA/sLYltDbPwRVkTueddgy Q2n/CaU7nOWcc7Dwwsit0XMbvc8FRDcCxnJ5DHmksyCXh59sa2ZEJoqM1vAxrPbH/W LQVuS4Ph3EWEyPAnAL3Ze3P4FWzpa5Hx3lTrX/Lo= Received: from send128.i.mail.ru (send128.i.mail.ru [89.221.237.223]) (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 ABFA915B1F7F for ; Fri, 24 Oct 2025 13:50:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org ABFA915B1F7F Received: by exim-smtp-855f5997bb-88mr2 with esmtpa (envelope-from ) id 1vCFNm-000000006vv-2jCh; Fri, 24 Oct 2025 13:50:55 +0300 To: Sergey Bronnikov Date: Fri, 24 Oct 2025 13:50:13 +0300 Message-ID: X-Mailer: git-send-email 2.51.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: 4F1203BC0FB41BD9DAB542EDD08389FE6972E6A35AEC2CEF82223B772369C626182A05F538085040A8B4F68E5CE349F03DE06ABAFEAF67054C2D0DF40548365152E7C6720268728E2770ED6FFD3D5E82 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70C5E0F71D77D667BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566D857902A848E84F8B8355EAE3EAFA2C3282EBDC4CF679BDE8432FF925E69B579389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C078FCF50C7EAF9C588941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B636DA1BED736F9328CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE74815913FF2B4FA25731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A54AC8B638681033085002B1117B3ED696E0CEBA28E79DE6A18B25839F35DFE037823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF973C8646E9BA64FA08785392131E8E90D412DD4D60B3764B9B68644BF7CBEEBCE547CA128C9EF4386EB503EC62A3E87F29DE04ECA18F893AE2422C6CC32E61FE8D7B8C79E363483A5F4332CA8FE04980913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVRN2q9QiacRu8Q0k1iPStZE= X-DA7885C5: 075D6C4CF5F77EE1F255D290C0D534F9C25792CAF8C73BDA0EB2C313EC440865C88CDD113FA0AEFB5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD2A2E2B56B9F506A9511988E4495A63B6E0C9D4869DDAA4698E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 luajit 09/41] perf: adjust fannkuch 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. --- I'm not sure that amount of permutations is the correct items count. Have you any other suggestions? perf/LuaJIT-benches/fannkuch.lua | 37 +++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua index 2a4cd426..c963c66f 100644 --- a/perf/LuaJIT-benches/fannkuch.lua +++ b/perf/LuaJIT-benches/fannkuch.lua @@ -1,3 +1,4 @@ +local bench = require("bench").new(arg) local function fannkuch(n) local p, q, s, odd, check, maxflips = {}, {}, {}, true, 0, 0 @@ -6,7 +7,7 @@ local function fannkuch(n) -- Print max. 30 permutations. if check < 30 then if not p[n] then return maxflips end -- Catch n = 0, 1, 2. - io.write(unpack(p)); io.write("\n") + -- io.write(unpack(p)); io.write("\n") check = check + 1 end -- Copy and flip. @@ -46,5 +47,35 @@ local function fannkuch(n) until false end -local n = tonumber(arg and arg[1]) or 1 -io.write("Pfannkuchen(", n, ") = ", fannkuch(n), "\n") +local n = tonumber(arg and arg[1]) or 11 + +-- Precomputed numbers taken from: +-- https://dl.acm.org/doi/pdf/10.1145/382109.382124 +local FANNKUCH = { 0, 1, 2, 4, 7, 10, 16, 22, 30, 38, 51, 65, 80 } + +local function factorial(n) + local fact = 1 + for i = 2, n do + fact = fact * i + end + return fact +end + +bench:add({ + name = "fannkuch", + payload = function() + return fannkuch(n) + end, + checker = function(res) + if n > #FANNKUCH then + -- Not precomputed, so can't check. + return true + else + return res == FANNKUCH[n] + end + end, + -- Assume that we count permutations here. + items = factorial(n), +}) + +bench:run_and_report() -- 2.51.0