Skip to content

Commit e028488

Browse files
committed
Sort Tnode headers before logging them
1 parent 56edbae commit e028488

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

arrayjit/lib/tnode.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,10 +761,17 @@ let get_values tn =
761761
let print_accessible_headers ?(pred = fun _ -> true) () =
762762
Stdio.printf "Tnode: collecting accessible arrays...%!\n";
763763
Stdlib.Gc.full_major ();
764-
Registry.iter (fun arr -> if pred arr then Stdio.print_endline @@ header arr) registry;
764+
let results =
765+
Registry.fold (fun arr acc -> if pred arr then (arr.id, header arr) :: acc else acc) registry []
766+
in
767+
List.sort results ~compare:(fun (a, _) (b, _) -> compare_int a b)
768+
|> List.iter ~f:(fun (_, header) -> Stdio.print_endline header);
765769
Stdio.printf "Tnode: Finished printing headers.%!\n"
766770
767771
let%debug_sexp log_accessible_headers ?(pred = fun _ -> true) () =
768772
Stdlib.Gc.full_major ();
769-
Registry.iter (fun arr -> if pred arr then [%log header arr]) registry;
770-
()
773+
let results =
774+
Registry.fold (fun arr acc -> if pred arr then (arr.id, header arr) :: acc else acc) registry []
775+
in
776+
List.sort results ~compare:(fun (a, _) (b, _) -> compare_int a b)
777+
|> List.iter ~f:(fun (_, header) -> [%log header])

0 commit comments

Comments
 (0)