diff --git a/Makefile b/Makefile index 98ac4679..dbe3780d 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/benchs/fib_rec.ml b/benchs/fib_rec.ml index 36d8c704..4ff984f4 100644 --- a/benchs/fib_rec.ml +++ b/benchs/fib_rec.ml @@ -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 "; "-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