File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ open Multicore_bench
2
+
3
+ let run_one ~budgetf ~n_domains () =
4
+ let n_bytes = 65536 in
5
+
6
+ let init _ =
7
+ let inn, out = Unix. pipe ~cloexec: true () in
8
+ (inn, out, Bytes. create 1 )
9
+ in
10
+ let work _ (inn , out , byte ) =
11
+ let n = Unix. write out (Bytes. create n_bytes) 0 n_bytes in
12
+ assert (n = n_bytes);
13
+ for _ = 1 to n_bytes do
14
+ let n : int = Unix. read inn byte 0 1 in
15
+ assert (n = 1 )
16
+ done ;
17
+ Unix. close inn;
18
+ Unix. close out
19
+ in
20
+
21
+ let config =
22
+ Printf. sprintf " %d worker%s" n_domains (if n_domains = 1 then " " else " s" )
23
+ in
24
+ Times. record ~budgetf ~n_domains ~n_warmups: 1 ~n_runs_min: 1 ~init ~work ()
25
+ |> Times. to_thruput_metrics ~n: (n_bytes * n_domains) ~singular: " blocking read"
26
+ ~config
27
+
28
+ let run_suite ~budgetf =
29
+ [ 1 ; 2 ; 4 ]
30
+ |> List. concat_map @@ fun n_domains ->
31
+ if Sys. win32 || Domain. recommended_domain_count () < n_domains then []
32
+ else run_one ~budgetf ~n_domains ()
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ let () =
15
15
(libraries
16
16
multicore-bench
17
17
backoff
18
+ unix
18
19
multicore-magic |}
19
20
^ maybe_domain_shims_and_threads ^ {| ))
20
21
|}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ let benchmarks =
5
5
(" Atomic" , Bench_atomic. run_suite);
6
6
(" Queue" , Bench_queue. run_suite);
7
7
(" Stack" , Bench_stack. run_suite);
8
+ (" Unix" , Bench_unix. run_suite);
8
9
]
9
10
10
11
let () = Multicore_bench.Cmd. run ~benchmarks ()
You can’t perform that action at this time.
0 commit comments