Add debugging information to the automaton.
authorKim Nguyễn <kn@lri.fr>
Fri, 15 Mar 2013 22:41:16 +0000 (23:41 +0100)
committerKim Nguyễn <kn@lri.fr>
Fri, 15 Mar 2013 22:41:16 +0000 (23:41 +0100)
src/auto/ata.ml

index af729da..ba2f55f 100644 (file)
@@ -14,7 +14,7 @@
 (***********************************************************************)
 
 (*
-  Time-stamp: <Last modified on 2013-03-15 18:18:11 CET by Kim Nguyen>
+  Time-stamp: <Last modified on 2013-03-15 23:38:04 CET by Kim Nguyen>
 *)
 
 INCLUDE "utils.ml"
@@ -178,13 +178,24 @@ let dummy2 = TransList.cons
 let dummy6 = (dummy2, StateSet.empty)
 
 
-let create s ss = { id = next ();
-                  states = s;
-                  selection_states = ss;
-                  transitions = Hashtbl.create 17;
-                  cache2 = Cache.N2.create dummy2;
-                  cache6 = Cache.N6.create dummy6;
- }
+let create s ss =
+  let auto = { id = next ();
+               states = s;
+               selection_states = ss;
+               transitions = Hashtbl.create 17;
+               cache2 = Cache.N2.create dummy2;
+               cache6 = Cache.N6.create dummy6;
+             }
+  in
+  at_exit (fun () ->
+    let n6 = ref 0 in
+    let n2 = ref 0 in
+    Cache.N2.iteri (fun _ _ _ b -> if b then incr n2) auto.cache2;
+    Cache.N6.iteri (fun _ _ _ _ _ _ _ b -> if b then incr n6) auto.cache6;
+    Format.eprintf "INFO: automaton %i, cache2: %i entries, cache6: %i entries\n%!"
+      (auto.id :> int) !n2 !n6
+  );
+  auto
 
 let reset a =
   a.cache2 <- Cache.N2.create dummy2;