Skip to content

Commit bac19d5

Browse files
committed
Add Loc.incr benchmark
1 parent 04d8b96 commit bac19d5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

bench/bench_loc.ml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
open Kcas
2+
open Bench
3+
4+
let run_one ?(factor = 1) ?(n_iter = 25 * factor * Util.iter_factor) () =
5+
let loc = Loc.make 0 in
6+
7+
let init _ = () in
8+
let work _ () =
9+
let rec loop i =
10+
if i > 0 then begin
11+
Loc.incr loc;
12+
loop (i - 1)
13+
end
14+
in
15+
loop n_iter
16+
in
17+
18+
let times = Times.record ~n_domains:1 ~init ~work () in
19+
20+
List.concat
21+
[
22+
Stats.of_times times
23+
|> Stats.scale (1_000_000_000.0 /. Float.of_int n_iter)
24+
|> Stats.to_json ~name:"time per op/incr"
25+
~description:"Time to perform a single op" ~units:"ns";
26+
Times.invert times |> Stats.of_times
27+
|> Stats.scale (Float.of_int n_iter /. 1_000_000.0)
28+
|> Stats.to_json ~name:"ops over time/incr"
29+
~description:"Number of operations performed over time" ~units:"M/s";
30+
]
31+
32+
let run_suite ~factor = run_one ~factor ()

bench/main.ml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let benchmarks =
22
[
3+
("Kcas Loc", Bench_loc.run_suite);
34
("Kcas Op", Bench_op.run_suite);
45
("Kcas Xt", Bench_xt.run_suite);
56
("Kcas parallel CMP", Bench_parallel_cmp.run_suite);

0 commit comments

Comments
 (0)