[Tarantool-patches] [PATCH v1 luajit 14/41] perf: adjust mandelbrot in LuaJIT-benches
Sergey Bronnikov
sergeyb at tarantool.org
Tue Dec 23 13:38:04 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 check the binary output, especially since it may be
> configured by the parameter.
> ---
> perf/LuaJIT-benches/mandelbrot.lua | 64 +++++++++++++++++++++---------
> 1 file changed, 45 insertions(+), 19 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/mandelbrot.lua b/perf/LuaJIT-benches/mandelbrot.lua
> index 0ef595a2..51e0dd4f 100644
> --- a/perf/LuaJIT-benches/mandelbrot.lua
> +++ b/perf/LuaJIT-benches/mandelbrot.lua
> @@ -1,23 +1,49 @@
> +local bench = require("bench").new(arg)
>
> -local write, char, unpack = io.write, string.char, unpack
> -local N = tonumber(arg and arg[1]) or 100
> -local M, ba, bb, buf = 2/N, 2^(N%8+1)-1, 2^(8-N%8), {}
> -write("P4\n", N, " ", N, "\n")
> -for y=0,N-1 do
> - local Ci, b, p = y*M-1, 1, 0
> - for x=0,N-1 do
> - local Cr = x*M-1.5
> - local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ci*Ci
> - b = b + b
> - for i=1,49 do
> - Zi = Zr*Zi*2 + Ci
> - Zr = Zrq-Ziq + Cr
> - Ziq = Zi*Zi
> - Zrq = Zr*Zr
> - if Zrq+Ziq > 4.0 then b = b + 1; break; end
> +local N = tonumber(arg and arg[1]) or 5000
> +
> +local function payload()
> + -- These functions must not be an upvalue but the stack slot.
> + local N = N
> + local write, char, unpack = io.write, string.char, unpack
> + local M, ba, bb, buf = 2/N, 2^(N%8+1)-1, 2^(8-N%8), {}
please add more whitespaces. Here and below.
> + write("P4\n", N, " ", N, "\n")
> + for y=0,N-1 do
> + local Ci, b, p = y*M-1, 1, 0
> + for x=0,N-1 do
> + local Cr = x*M-1.5
> + local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ci*Ci
> + b = b + b
> + for i=1,49 do
> + Zi = Zr*Zi*2 + Ci
> + Zr = Zrq-Ziq + Cr
> + Ziq = Zi*Zi
> + Zrq = Zr*Zr
> + if Zrq+Ziq > 4.0 then b = b + 1; break; end
> + end
> + if b >= 256 then p = p + 1; buf[p] = 511 - b; b = 1; end
> end
> - if b >= 256 then p = p + 1; buf[p] = 511 - b; b = 1; end
> + if b ~= 1 then p = p + 1; buf[p] = (ba-b)*bb; end
> + write(char(unpack(buf, 1, p)))
> end
> - if b ~= 1 then p = p + 1; buf[p] = (ba-b)*bb; end
> - write(char(unpack(buf, 1, p)))
> end
> +
> +local stdout = io.output()
> +
> +bench:add({
> + name = "mandelbrot",
> + items = N,
> + -- XXX: This is inconvenient to have the binary file in the
> + -- repository for the comparison. If the check is needed run,
> + -- the payload manually.
> + skip_check = true,
> + setup = function()
> + io.output("/dev/null")
> + end,
> + teardown = function()
> + io.output(stdout)
> + end,
> + payload = payload,
> +})
> +
> +bench:run_and_report()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20251223/6392478a/attachment.htm>
More information about the Tarantool-patches
mailing list