@@ -19,6 +19,8 @@ def __init__(self, lvl):
1919 self .nr_merged_states = 0
2020 self .nr_red_states = 0
2121
22+ self .stats = dict ()
23+
2224 self .previous_time = None
2325
2426 def reset (self , gsm : GeneralizedStateMerging ):
@@ -29,23 +31,27 @@ def reset(self, gsm: GeneralizedStateMerging):
2931 self .nr_merged_states = 0
3032 self .nr_red_states = 0
3133
34+ self .stats = dict ()
3235 self .previous_time = perf_counter ()
3336
3437 def pta_construction_done (self , root ):
35- print (f'PTA Construction Time: { round (perf_counter () - self .previous_time , 2 )} s' )
36- if 1 < self .lvl :
38+ pta_const_time = perf_counter () - self .previous_time
39+ self .stats ["pta creation time" ] = pta_const_time
40+ print (f'PTA Construction Time: { round (pta_const_time , 2 )} s' )
41+ if 0 < self .lvl :
3742 states = root .get_all_nodes ()
3843 leafs = [state for state in states if len (state .transitions .keys ()) == 0 ]
3944 depth = [state .get_prefix_length () for state in leafs ]
4045 self .pta_size = len (states )
41- print (f'PTA has { len (states )} states leading to { len (leafs )} leafs' )
42- print (f'min / avg / max depth : { min (depth )} / { sum (depth ) / len (depth )} / { max (depth )} ' )
46+ if 1 < self .lvl :
47+ print (f'PTA has { len (states )} states leading to { len (leafs )} leafs' )
48+ print (f'min / avg / max depth : { min (depth )} / { sum (depth ) / len (depth )} / { max (depth )} ' )
4349 self .previous_time = perf_counter ()
4450
4551 def print_status (self ):
4652 reset_char = "\33 [2K\r "
4753 print_str = reset_char + f'Current automaton size: { self .nr_red_states } '
48- if 1 < self .lvl and not self .gsm .compatibility_on_futures :
54+ if 0 < self .lvl and not self .gsm .compatibility_on_futures :
4955 print_str += f' Merged: { self .nr_merged_states_total } Remaining: { self .pta_size - self .nr_red_states - self .nr_merged_states_total } '
5056 print (print_str , end = "" )
5157
@@ -61,7 +67,10 @@ def log_merge(self, part: Partitioning):
6167 self .print_status ()
6268
6369 def learning_done (self , root : GsmNode ):
64- print (f'\n Learning Time: { round (perf_counter () - self .previous_time , 2 )} s' )
70+ learning_time = perf_counter () - self .previous_time
71+ self .stats ["learning time" ] = learning_time
72+ self .stats ["total time" ] = learning_time + self .stats ["pta creation time" ]
73+ print (f'\n Learning Time: { round (learning_time , 2 )} s' )
6574 print (f'Learned { self .nr_red_states } state automaton via { self .nr_merged_states } merges.' )
6675 if 2 < self .lvl :
6776 root .visualize ("model" , self .gsm .output_behavior )
0 commit comments