[Tarantool-patches] [PATCH v1 luajit 35/41] perf: adjust spectral-norm in LuaJIT-benches
Sergey Bronnikov
sergeyb at tarantool.org
Mon Nov 17 17:23:28 MSK 2025
Hi, Sergey,
thanks for the patch! See my comments below.
Sergey
On 10/24/25 14:00, 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.
> ---
> perf/LuaJIT-benches/spectral-norm.lua | 40 +++++++++++++++++++--------
> 1 file changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/spectral-norm.lua b/perf/LuaJIT-benches/spectral-norm.lua
> index ecc80112..6e63cd47 100644
> --- a/perf/LuaJIT-benches/spectral-norm.lua
> +++ b/perf/LuaJIT-benches/spectral-norm.lua
> @@ -1,3 +1,4 @@
> +local bench = require("bench").new(arg)
>
> local function A(i, j)
> local ij = i+j-1
> @@ -25,16 +26,33 @@ local function AtAv(x, y, t, N)
> Atv(t, y, N)
> end
>
> -local N = tonumber(arg and arg[1]) or 100
> -local u, v, t = {}, {}, {}
> -for i=1,N do u[i] = 1 end
> +local N = tonumber(arg and arg[1]) or 3000
Why it was changed to 3000?
>
> -for i=1,10 do AtAv(u, v, t, N) AtAv(v, u, t, N) end
> +bench:add({
> + name = "spectral_norm",
> + checker = function(res)
> + -- XXX: Empirical value.
> + if N > 66 then
> + assert(math.abs(res - 1.27422) < 0.00001)
> + end
> + return true
> + end,
> + payload = function()
> + local u, v, t = {}, {}, {}
> + for i=1,N do u[i] = 1 end
add more whitespaces, here and below
>
> -local vBv, vv = 0, 0
> -for i=1,N do
> - local ui, vi = u[i], v[i]
> - vBv = vBv + ui*vi
> - vv = vv + vi*vi
> -end
> -io.write(string.format("%0.9f\n", math.sqrt(vBv / vv)))
> + for i=1,10 do AtAv(u, v, t, N) AtAv(v, u, t, N) end
> +
> + local vBv, vv = 0, 0
> + for i=1,N do
> + local ui, vi = u[i], v[i]
> + vBv = vBv + ui*vi
> + vv = vv + vi*vi
> + end
> + return math.sqrt(vBv / vv)
> + end,
> + -- Operations inside `for i=1,10` loop.
> + items = 40 * N * N,
> +})
> +
> +bench:run_and_report()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20251117/4aa7c81b/attachment.htm>
More information about the Tarantool-patches
mailing list