bench fib: additional parameter

This commit is contained in:
Simon Cruanes 2023-06-08 15:10:14 -04:00
parent ab2d8d4956
commit 027d39e9a5
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 6 additions and 2 deletions

View file

@ -21,10 +21,11 @@ DUNE_OPTS_BENCH?=--profile=release
N?=40
NITER?=3
BENCH_PSIZE?=1,4,8,20
BENCH_CUTOFF?=20
bench-fib:
@echo running for N=$(N)
dune build $(DUNE_OPTS_BENCH) benchs/fib_rec.exe
hyperfine -L psize $(BENCH_PSIZE) \
'./_build/default/benchs/fib_rec.exe -niter $(NITER) -psize={psize} -n $(N)'
'./_build/default/benchs/fib_rec.exe -cutoff $(BENCH_CUTOFF) -niter $(NITER) -psize={psize} -n $(N)'
.PHONY: test clean

View file

@ -6,8 +6,10 @@ let rec fib_direct x =
else
fib_direct (x - 1) + fib_direct (x - 2)
let cutoff = ref 20
let rec fib ~on x : int Fut.t =
if x <= 20 then
if x <= !cutoff then
Fut.spawn ~on (fun () -> fib_direct x)
else
let open Fut.Infix_local in
@ -42,6 +44,7 @@ let () =
"-n", Arg.Set_int n, " fib <n>";
"-seq", Arg.Set seq, " sequential";
"-niter", Arg.Set_int niter, " number of iterations";
"-cutoff", Arg.Set_int cutoff, " cutoff for sequential computation";
]
|> Arg.align
in