Skip to content

Commit

Permalink
Add Loc.incr benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Dec 20, 2023
1 parent 3e228ce commit d7441e3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions bench/bench_loc.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
open Kcas
open Bench

let run_one ?(factor = 1) ?(n_iter = 25 * factor * Util.iter_factor) () =
let loc = Loc.make 0 in

let init _ = () in
let work _ () =
let rec loop i =
if i > 0 then begin
Loc.incr loc;
loop (i - 1)
end
in
loop n_iter
in

let times = Times.record ~n_domains:1 ~init ~work () in

List.concat
[
Stats.of_times times
|> Stats.scale (1_000_000_000.0 /. Float.of_int n_iter)
|> Stats.to_json ~name:"time per op/incr"
~description:"Time to perform a single op" ~units:"ns";
Times.invert times |> Stats.of_times
|> Stats.scale (Float.of_int n_iter /. 1_000_000.0)
|> Stats.to_json ~name:"ops over time/incr"
~description:"Number of operations performed over time" ~units:"M/s";
]

let run_suite ~factor = run_one ~factor ()
1 change: 1 addition & 0 deletions bench/main.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
let benchmarks =
[
("Kcas Loc", Bench_loc.run_suite);
("Kcas Op", Bench_op.run_suite);
("Kcas Xt", Bench_xt.run_suite);
("Kcas parallel CMP", Bench_parallel_cmp.run_suite);
Expand Down

0 comments on commit d7441e3

Please sign in to comment.