From aace0fdd9c24437ad8ecb03a0cc4e70db45b6fc9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kim=20Nguy=E1=BB=85n?= Date: Fri, 15 Mar 2013 23:41:16 +0100 Subject: [PATCH] Add debugging information to the automaton. --- src/auto/ata.ml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/auto/ata.ml b/src/auto/ata.ml index af729da..ba2f55f 100644 --- a/src/auto/ata.ml +++ b/src/auto/ata.ml @@ -14,7 +14,7 @@ (***********************************************************************) (* - Time-stamp: + Time-stamp: *) 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; -- 2.17.1