Skip to content

Commit

Permalink
Prefer to set in init
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Feb 25, 2024
1 parent a3e3fd7 commit de04533
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bench/bench_hashtbl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ let run_one ~budgetf ~n_domains ?(n_ops = 40 * Util.iter_factor)
Hashtbl.replace t i i
done;

let n_ops_todo = Atomic.make n_ops |> Multicore_magic.copy_as_padded in
let n_ops_todo = Atomic.make 0 |> Multicore_magic.copy_as_padded in

let init _ = Random.State.make_self_init () in
let init _ =
Atomic.set n_ops_todo n_ops;
Random.State.make_self_init ()
in

let work _ state =
let rec work () =
Expand All @@ -46,15 +49,14 @@ let run_one ~budgetf ~n_domains ?(n_ops = 40 * Util.iter_factor)
in
work ()
in
let after () = Atomic.set n_ops_todo n_ops in

let config =
Printf.sprintf "%d worker%s, %d%% reads" n_domains
(if n_domains = 1 then "" else "s")
percent_read
in

Times.record ~budgetf ~n_domains ~init ~work ~after ()
Times.record ~budgetf ~n_domains ~init ~work ()
|> Times.to_thruput_metrics ~n:n_ops ~singular:"operation" ~config

let run_suite ~budgetf =
Expand Down

0 comments on commit de04533

Please sign in to comment.