Skip to content

Commit 3ea8caf

Browse files
committed
Fix tests to pass on FreeBSD
1 parent 1cdcace commit 3ea8caf

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

bench/bench_unix.ml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
open Multicore_bench
22

33
let run_one ~budgetf ~n_domains () =
4-
let n_bytes = 65536 in
4+
let block_size = 4096 in
5+
let n_blocks = 16 in
56

67
let init _ =
78
let inn, out = Unix.pipe ~cloexec:true () in
8-
(inn, out, Bytes.create 1)
9+
(inn, out, Bytes.create block_size, Bytes.create 1)
910
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)
11+
let work _ (inn, out, block, byte) =
12+
for _ = 1 to n_blocks do
13+
let n = Unix.write out block 0 block_size in
14+
assert (n = block_size);
15+
for _ = 1 to block_size do
16+
let n : int = Unix.read inn byte 0 1 in
17+
assert (n = 1)
18+
done
1619
done;
1720
Unix.close inn;
1821
Unix.close out
@@ -22,8 +25,9 @@ let run_one ~budgetf ~n_domains () =
2225
Printf.sprintf "%d worker%s" n_domains (if n_domains = 1 then "" else "s")
2326
in
2427
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
28+
|> Times.to_thruput_metrics
29+
~n:(block_size * n_blocks * n_domains)
30+
~singular:"blocking read" ~config
2731

2832
let run_suite ~budgetf =
2933
[ 1; 2; 4 ]

0 commit comments

Comments
 (0)