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

Sergey Bronnikov sergeyb at tarantool.org
Mon Nov 17 16:25:49 MSK 2025


Hi, Sergey,

thanks for the patch! See my comments.

Sergey

On 10/24/25 13:50, 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 | 49 ++++++++++++++++++--------
>   1 file changed, 35 insertions(+), 14 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/pidigits-nogmp.lua b/perf/LuaJIT-benches/pidigits-nogmp.lua
> index 63a1cb0e..e96b3e45 100644
> --- a/perf/LuaJIT-benches/pidigits-nogmp.lua
> +++ b/perf/LuaJIT-benches/pidigits-nogmp.lua
> @@ -1,3 +1,4 @@
> +local bench = require("bench").new(arg)
>   
>   -- Start of dynamically compiled chunk.
>   local chunk = [=[
> @@ -80,21 +81,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
Why 5000 by default?
>   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
add more whitespaces, here and below
> -  io.write(string.rep(" ", 10-n10), "\t:", N, "\n")
> -end
> +    -- 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
> +
> +    -- 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
> +  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/20251117/6450e398/attachment.htm>


More information about the Tarantool-patches mailing list