[Tarantool-patches] [PATCH v2 luajit 25/41] perf: adjust recursive-fib in LuaJIT-benches
Sergey Bronnikov
sergeyb at tarantool.org
Fri Jan 2 18:31:45 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.
> ---
> perf/LuaJIT-benches/recursive-fib.lua | 33 +++++++++++++++++++++++++--
> 1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/perf/LuaJIT-benches/recursive-fib.lua b/perf/LuaJIT-benches/recursive-fib.lua
> index ef9950de..8e96934a 100644
> --- a/perf/LuaJIT-benches/recursive-fib.lua
> +++ b/perf/LuaJIT-benches/recursive-fib.lua
> @@ -1,7 +1,36 @@
> +-- The benchmark to check the performance of recursive calls.
> +-- Calculates the Fibonacci values recursively.
> +-- For the details see:
> +--http://mathworld.wolfram.com/FibonacciNumber.html
> +
> +local bench = require("bench").new(arg)
> +
> local function fib(n)
> if n < 2 then return 1 end
> return fib(n-2) + fib(n-1)
> end
>
> -local n = tonumber(arg[1]) or 10
> -io.write(string.format("Fib(%d): %d\n", n, fib(n)))
> +local n = tonumber(arg[1]) or 40
> +
> +local benchmark
> +benchmark = {
> + name = "recursive_fib",
> + checker = function(res)
> + local km1, k = 1, 1
> + for i = 2, n do
> + local tmp = k + km1
> + km1 = k
> + k = tmp
> + end
> + return k == res
> + end,
> + payload = function()
> + local res = fib(n)
> + -- Number of calls.
> + benchmark.items = res * 2 - 1
> + return res
> + end,
> +}
> +
> +bench:add(benchmark)
> +bench:run_and_report()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20260102/9028d4ad/attachment.htm>
More information about the Tarantool-patches
mailing list