Skip to content

Commit 5de8e09

Browse files
committed
make the test differential (probably more robust)
1 parent 049a24e commit 5de8e09

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

testsuite/tests/lib-runtime-events/test_instrumented.ml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,34 @@ let runtime_end domain_id ts phase =
2525
let lost_events domain_id words =
2626
lost_event_words := !lost_event_words + words
2727

28+
let callbacks = Callbacks.create ~runtime_end ~alloc ~lost_events ()
29+
30+
let reset cursor =
31+
ignore (read_poll cursor callbacks None);
32+
total_blocks := 0;
33+
total_minors := 0
34+
35+
let loop n cursor =
36+
Gc.full_major ();
37+
reset cursor;
38+
let minors_before = Gc.((quick_stat ()).minor_collections) in
39+
for a = 1 to n do
40+
list_ref := (Sys.opaque_identity(ref 42)) :: !list_ref
41+
done;
42+
Gc.full_major ();
43+
ignore(read_poll cursor callbacks None);
44+
let minors_after = Gc.((quick_stat ()).minor_collections) in
45+
minors_after - minors_before
46+
2847
let () =
29-
Gc.full_major ();
30-
let stat1 = Gc.quick_stat () in
31-
start ();
32-
let cursor = create_cursor None in
33-
for a = 0 to 1_000_000 do
34-
list_ref := (Sys.opaque_identity(ref 42)) :: !list_ref
35-
done;
36-
Gc.full_major ();
37-
let callbacks = Callbacks.create ~runtime_end ~alloc ~lost_events () in
38-
ignore(read_poll cursor callbacks None);
39-
let stat2 = Gc.quick_stat () in
40-
let self_minors =
41-
Sys.opaque_identity (stat2).Gc.minor_collections
42-
- Sys.opaque_identity (stat1).Gc.minor_collections
43-
in
44-
Printf.printf "lost_event_words: %d, total_blocks: %d, diff_minors: %d\n"
45-
!lost_event_words !total_blocks (!total_minors - self_minors)
48+
start ();
49+
let cursor = create_cursor None in
50+
let self_minors_base = loop 0 cursor in
51+
let blocks_base = !total_blocks in
52+
let minors_base = !total_minors in
53+
let self_minors = loop 1_000_000 cursor - self_minors_base in
54+
let blocks = !total_blocks in
55+
let minors = !total_minors in
56+
Printf.printf "lost_event_words: %d, total_blocks: %d, diff_minors: %d\n"
57+
!lost_event_words (blocks - blocks_base)
58+
(minors - minors_base - self_minors)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lost_event_words: 0, total_blocks: 2000008, diff_minors: 0
1+
lost_event_words: 0, total_blocks: 2000000, diff_minors: 0

0 commit comments

Comments
 (0)