Skip to content

Commit 86b2b3d

Browse files
committed
Use wrap to potentially slightly reduce overhead
1 parent 4ac7d5b commit 86b2b3d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

bench/bench_fib.ocaml5.ml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@ let run_one_randos ~budgetf ~n_domains ~n () =
2424

2525
let before _ = context := Randos.context () in
2626
let init _ = !context in
27+
let wrap i context action =
28+
if i = 0 then Randos.run ~context action else action ()
29+
in
2730
let work i context =
28-
if i <> 0 then Randos.runner_on_this_thread context
29-
else ignore @@ Randos.run ~context @@ fun () -> exp_fib n
31+
if i <> 0 then Randos.runner_on_this_thread context else ignore @@ exp_fib n
3032
in
3133

3234
let config =
3335
Printf.sprintf "%d rando%s, fib %d" n_domains
3436
(if n_domains = 1 then "" else "s")
3537
n
3638
in
37-
Times.record ~budgetf ~n_domains ~before ~init ~work ()
39+
Times.record ~budgetf ~n_domains ~before ~init ~wrap ~work ()
3840
|> Times.to_thruput_metrics
3941
~n:(Float.to_int (Float.of_int (lin_fib n) *. ratio))
4042
~singular:"spawn" ~config
@@ -46,17 +48,20 @@ let run_one_multififos ~budgetf ~n_domains ~n () =
4648

4749
let before _ = context := Multififos.context () in
4850
let init _ = !context in
51+
let wrap i context action =
52+
if i = 0 then Multififos.run ~context action else action ()
53+
in
4954
let work i context =
5055
if i <> 0 then Multififos.runner_on_this_thread context
51-
else ignore @@ Multififos.run ~context @@ fun () -> exp_fib n
56+
else ignore @@ exp_fib n
5257
in
5358

5459
let config =
5560
Printf.sprintf "%d mfifo%s, fib %d" n_domains
5661
(if n_domains = 1 then "" else "s")
5762
n
5863
in
59-
Times.record ~budgetf ~n_domains ~before ~init ~work ()
64+
Times.record ~budgetf ~n_domains ~before ~init ~wrap ~work ()
6065
|> Times.to_thruput_metrics
6166
~n:(Float.to_int (Float.of_int (lin_fib n) *. ratio))
6267
~singular:"spawn" ~config

0 commit comments

Comments
 (0)