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 422AC16BF2E1; Fri, 26 Dec 2025 12:29:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 422AC16BF2E1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766741394; bh=D91f5VAYYZZyYWUX3cfLgsjWzvmXibyKY4g4/B2lGfw=; 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=DutwOBBeZNexEC2OusmMgss5a3THe+8WsUW9Zs2QKlhXIoChtyr6Qe/qfrC1byVLw xmQKm+hfOHxXWc5zeN1Jl7HF/JiL+IlpXqctYmfDXxKJjXj87/gMy77FnvN94V0AIs NQ3F8CsdJWW/Po3r4AD4HtfKvNvbPGgNh7OI+jkQ= Received: from send264.i.mail.ru (send264.i.mail.ru [95.163.59.103]) (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 1B1A416C659A for ; Fri, 26 Dec 2025 12:19:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1B1A416C659A Received: by exim-smtp-7b4fb89df9-lft7n with esmtpa (envelope-from ) id 1vZ3yS-000000008Cp-49Sr; Fri, 26 Dec 2025 12:19:05 +0300 To: Sergey Bronnikov Date: Fri, 26 Dec 2025 12:17:54 +0300 Message-ID: <6250686d102f69ae25d85f179a8d96832a35e35a.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: 4F1203BC0FB41BD979975AF0D777FEBDB5A0B7D2FFA411B6E217FB390AD6DF18182A05F538085040E358ECEA5BFFDEEF3DE06ABAFEAF6705DE0D94894887520DB4FA2C6BBBE99EF9BE26E60622977F24 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B264C8851FD8E810EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C8694CDA63C95A2D22128EDCD39A7D089D1A97D9D946029A8B9A389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C04CF195F1528592878941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6E5E764EB5D94DBD4CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE778B471BB9634AD8A731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5571032E13C7E5C155002B1117B3ED696B44EE60154B62E766E5F408120975D33823CB91A9FED034534781492E4B8EEADD0953842B444AAC3C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6593AF55A89FD0745B859A302C0EA5D52F5D56A66C77AFCB2F982ED939E8DAA029834F0E6BD41B91AA6B8341EE9D5BE9A0A27CF28362CD4EFCA05D8439B09F6DFF0A678FAC43EDB676A6536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXbA/Rf48PZTEQ= X-DA7885C5: 25C200E46A5FBEC4F255D290C0D534F954337C85044D6B33623A37F3A1703A22BA0C09C5F17DF0B35B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD28472807A502C15B28700636FE984EBB884DF7E92CF228913E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 23/41] perf: adjust ray 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 output is redirected to /dev/null. The check is skipped since it is very inconvenient to check the binary output, especially since it may be configured by the parameter. --- perf/LuaJIT-benches/ray.lua | 83 +++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/perf/LuaJIT-benches/ray.lua b/perf/LuaJIT-benches/ray.lua index 2acc24c0..f322b023 100644 --- a/perf/LuaJIT-benches/ray.lua +++ b/perf/LuaJIT-benches/ray.lua @@ -1,10 +1,12 @@ +-- Benchmark to check the performance of FP arithmetics and +-- structure accesses via modeling of ray tracing. The benchmark +-- generates the fractal image of spheres in the PGM format. + +local bench = require("bench").new(arg) + local sqrt = math.sqrt local huge = math.huge - -local delta = 1 -while delta * delta + 1 ~= 1 do - delta = delta * 0.5 -end +local delta local function length(x, y, z) return sqrt(x*x + y*y + z*z) end local function vlen(v) return length(v[1], v[2], v[3]) end @@ -110,26 +112,55 @@ end local level, n, ss = tonumber(arg[1]) or 9, tonumber(arg[2]) or 256, 4 -local iss = 1/ss -local gf = 255/(ss*ss) - -io.write(("P5\n%d %d\n255\n"):format(n, n)) -local light = { unitise(-1, -3, 2) } -ilight = { -light[1], -light[2], -light[3] } -local camera = { 0, 0, -4 } -local dir = { 0, 0, 0 } - -local scene = create(level, {0, -1, 0}, 1) - -for y = n/2-1, -n/2, -1 do - for x = -n/2, n/2-1 do - local g = 0 - for d = y, y+.99, iss do - for e = x, x+.99, iss do - dir[1], dir[2], dir[3] = unitise(e, d, n) - g = g + ray_trace(light, camera, dir, scene) + +local stdout = io.output() + +bench:add({ + name = "ray", + -- Avoid skip checking here, since it is not very convenient. + -- If you want to check the behaviour -- drop the setup + -- function. + skip_check = true, + setup = function() + io.output("/dev/null") + end, + payload = function() + -- Cache to avoid upvalue lookups. + local level, n, ss = level, n, ss + + local iss = 1 / ss + local gf = 255 / (ss * ss) + + delta = 1 + while delta * delta + 1 ~= 1 do + delta = delta * 0.5 + end + + io.write(("P5\n%d %d\n255\n"):format(n, n)) + local light = { unitise(-1, -3, 2) } + ilight = { -light[1], -light[2], -light[3] } + local camera = { 0, 0, -4 } + local dir = { 0, 0, 0 } + + local scene = create(level, {0, -1, 0}, 1) + + for y = n / 2 - 1, -n / 2, -1 do + for x = -n / 2, n / 2 - 1 do + local g = 0 + for d = y, y + .99, iss do + for e = x, x + .99, iss do + dir[1], dir[2], dir[3] = unitise(e, d, n) + g = g + ray_trace(light, camera, dir, scene) + end + end + io.write(string.char(math.floor(0.5 + g * gf))) end end - io.write(string.char(math.floor(0.5 + g*gf))) - end -end + end, + teardown = function() + io.output(stdout) + end, + items = n * n * level, +}) + +bench:run_and_report() -- 2.52.0