[Tarantool-patches] [PATCH v2 luajit 22/41] perf: adjust pidigits-nogmp in LuaJIT-benches

Sergey Bronnikov sergeyb at tarantool.org
Fri Jan 2 14:07:16 MSK 2026


Hi, Sergey!

thanks for the patch! LGTM

Sergey

On 12/26/25 12:17, 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 output is redirected to /dev/null. The check is skipped since it is
> very inconvenient to store the huge file in the repository with the
> reference value.
> ---
>   perf/LuaJIT-benches/pidigits-nogmp.lua | 56 +++++++++++++++++++-------
>   1 file changed, 42 insertions(+), 14 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/pidigits-nogmp.lua b/perf/LuaJIT-benches/pidigits-nogmp.lua
> index 63a1cb0e..cdfa7fcb 100644
> --- a/perf/LuaJIT-benches/pidigits-nogmp.lua
> +++ b/perf/LuaJIT-benches/pidigits-nogmp.lua
> @@ -1,3 +1,11 @@
> +-- The benchmark to check the performance of arithmetic operations
> +-- array accesses simulating the multi-precision number
> +-- operations and the streaming output to the stdout. This
> +-- benchmark calculates the first numbers of Pi.
> +-- For the details see:
> +--https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/pidigits.html
> +
> +local bench = require("bench").new(arg)
>   
>   -- Start of dynamically compiled chunk.
>   local chunk = [=[
> @@ -80,21 +88,41 @@ end)
>   
>   ]=] -- End of dynamically compiled chunk.
>   
> -local N = tonumber(arg and arg[1]) or 27
> +local N = tonumber(arg and arg[1]) or 5000
>   local RADIX = N < 6500 and 2^36 or 2^32 -- Avoid overflow.
>   
> --- Substitute radix and compile chunk.
> -local pidigit = loadstring(string.gsub(chunk, "RADIX", tostring(RADIX)))()
> +local stdout = io.output()
>   
> --- Print lines with 10 digits.
> -for i=10,N,10 do
> -  for j=1,10 do io.write(pidigit()) end
> -  io.write("\t:", i, "\n")
> -end
> +bench:add({
> +  name = "pidigit_nogmp",
> +  -- 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()
> +    -- Substitute radix and compile chunk.
> +    local pidigit = loadstring(string.gsub(chunk, "RADIX", tostring(RADIX)))()
>   
> --- Print remaining digits (if any).
> -local n10 = N % 10
> -if n10 ~= 0 then
> -  for i=1,n10 do io.write(pidigit()) end
> -  io.write(string.rep(" ", 10-n10), "\t:", N, "\n")
> -end
> +    -- Print lines with 10 digits.
> +    for i = 10, N, 10 do
> +      for _ = 1, 10 do io.write(pidigit()) end
> +      io.write("\t:", i, "\n")
> +    end
> +
> +    -- Print remaining digits (if any).
> +    local n10 = N % 10
> +    if n10 ~= 0 then
> +      for _ = 1, n10 do io.write(pidigit()) end
> +      io.write(string.rep(" ", 10 - n10), "\t:", N, "\n")
> +    end
> +  end,
> +  teardown = function()
> +    io.output(stdout)
> +  end,
> +  items = N,
> +})
> +
> +bench:run_and_report()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20260102/dd12d143/attachment.htm>


More information about the Tarantool-patches mailing list