Skip to content

Commit fc7f569

Browse files
committed
Extract Hashtbl stats to GobHashtbl module
1 parent e0faa22 commit fc7f569

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/framework/cfgTools.ml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,7 @@ let createCFG (file: file) =
483483
if not (NH.mem reachable_return' (FunctionEntry fd)) then
484484
raise (Not_connect fd);
485485

486-
let module NH2 = Hashtbl.Make (Node) in
487-
let stats (h: 'a NH.t) =
488-
let h': 'a NH2.t = Obj.magic h in
489-
let s = NH2.stats h' in
490-
Format.eprintf "stats: bindings=%d buckets=%d max_length=%d histo=%a load=%f\n" s.num_bindings s.num_buckets s.max_bucket_length (Format.pp_print_list ~pp_sep:(fun f () -> Format.pp_print_char f ',') Format.pp_print_int) (Array.to_list s.bucket_histogram) (float_of_int s.num_bindings /. float_of_int s.num_buckets);
491-
in
492-
stats cfgF;
493-
stats cfgB;
486+
ignore (Pretty.eprintf "%a: cfgF (%a), cfgB (%a)\n" CilType.Fundec.pretty fd GobHashtbl.pretty_statistics (GobHashtbl.magic_stats cfgF) GobHashtbl.pretty_statistics (GobHashtbl.magic_stats cfgB));
494487
FH.replace cfgs fd (cfgF, cfgB);
495488
| _ -> ()
496489
);

src/util/gobHashtbl.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let magic_stats h =
2+
let h: _ Hashtbl.t = Obj.magic h in (* Batteries Hashtables don't expose stats... *)
3+
Hashtbl.stats h
4+
5+
let pretty_statistics () (s: Hashtbl.statistics) =
6+
let load_factor = float_of_int s.num_bindings /. float_of_int s.num_buckets in
7+
Pretty.dprintf "bindings=%d buckets=%d max_length=%d histo=%a load=%f" s.num_bindings s.num_buckets s.max_bucket_length (Pretty.docList (Pretty.dprintf "%d")) (Array.to_list s.bucket_histogram) load_factor

0 commit comments

Comments
 (0)