Skip to content

Commit 8282e2b

Browse files
committed
Perform Picos_stdio.Unix bench using multiple smaller blocks
This mirrors change in a similar benchmark in multicore-bench.
1 parent 83b3c2b commit 8282e2b

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

bench/bench_stdio.ml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@ open Multicore_bench
22
open Picos_stdio
33

44
let run_one ~budgetf ~block_or_nonblock ~n_domains () =
5-
let n_bytes =
6-
match block_or_nonblock with `Block -> 4096 | `Nonblock -> 65536
7-
in
5+
let block_size = 4096 in
6+
let n_blocks = match block_or_nonblock with `Block -> 1 | `Nonblock -> 16 in
87

98
let init _ =
109
let inn, out = Unix.pipe ~cloexec:true () in
11-
(inn, out, Bytes.create 1)
10+
(inn, out, Bytes.create block_size, Bytes.create 1)
1211
in
1312
let wrap _ _ = Scheduler.run in
14-
let work _ (inn, out, byte) =
13+
let work _ (inn, out, block, byte) =
1514
begin
1615
match block_or_nonblock with
1716
| `Block -> ()
1817
| `Nonblock -> Unix.set_nonblock inn
1918
end;
20-
let n = Unix.write out (Bytes.create n_bytes) 0 n_bytes in
21-
assert (n = n_bytes);
22-
for _ = 1 to n_bytes do
23-
let n : int = Unix.read inn byte 0 1 in
24-
assert (n = 1)
19+
for _ = 1 to n_blocks do
20+
let n = Unix.write out block 0 block_size in
21+
assert (n = block_size);
22+
for _ = 1 to block_size do
23+
let n : int = Unix.read inn byte 0 1 in
24+
assert (n = 1)
25+
done
2526
done;
2627
Unix.close inn;
2728
Unix.close out
@@ -39,7 +40,9 @@ let run_one ~budgetf ~block_or_nonblock ~n_domains () =
3940
| `Block -> "blocking read"
4041
| `Nonblock -> "non-blocking read"
4142
in
42-
Times.to_thruput_metrics ~n:(n_bytes * n_domains) ~singular ~config times
43+
Times.to_thruput_metrics
44+
~n:(block_size * n_blocks * n_domains)
45+
~singular ~config times
4346

4447
let run_suite ~budgetf =
4548
Util.cross [ `Nonblock; `Block ] [ 1; 2; 4 ]

0 commit comments

Comments
 (0)