[Tarantool-patches] [PATCH v1 luajit 20/41] perf: adjust nsieve in LuaJIT-benches
Sergey Bronnikov
sergeyb at tarantool.org
Mon Nov 17 16:25:58 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.
> ---
> perf/LuaJIT-benches/nsieve.lua | 35 +++++++++++++++++++++++++++++-----
> 1 file changed, 30 insertions(+), 5 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/nsieve.lua b/perf/LuaJIT-benches/nsieve.lua
> index 6de0524f..2d1b66c8 100644
> --- a/perf/LuaJIT-benches/nsieve.lua
> +++ b/perf/LuaJIT-benches/nsieve.lua
> @@ -1,3 +1,4 @@
> +local bench = require("bench").new(arg)
>
> local function nsieve(p, m)
> for i=2,m do p[i] = true end
> @@ -11,11 +12,35 @@ local function nsieve(p, m)
> return count
> end
>
> -local N = tonumber(arg and arg[1]) or 1
> +local DEFAULT_N = 12
Why 12?
> +local N = tonumber(arg and arg[1]) or DEFAULT_N
> if N < 2 then N = 2 end
> local primes = {}
>
> -for i=0,2 do
> - local m = (2^(N-i))*10000
> - io.write(string.format("Primes up to %8d %8d\n", m, nsieve(primes, m)))
> -end
> +local benchmark
> +benchmark = {
> + name = "nsieve",
> + payload = function()
> + local res = {}
> + local items = 0
> + for i=0,2 do
add more whitespaces, here and below
> + local m = (2^(N-i))*10000
> + items = items + m
> + res[i] = nsieve(primes, m)
> + end
> + benchmark.items = items
> +
> + return res
> + end,
> + checker = function(res)
> + if N == DEFAULT_N then
> + assert(res[0] == 2488465)
> + assert(res[1] == 1299069)
> + assert(res[2] == 679461)
> + end
> + return true
> + end,
> +}
> +
> +bench:add(benchmark)
> +bench:run_and_report()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20251117/746f01b3/attachment.htm>
More information about the Tarantool-patches
mailing list