Skip to content

Commit 269cc9c

Browse files
committed
use perf counter and better msg for ProgressReport
1 parent c6d8c62 commit 269cc9c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

aalpy/learning_algs/general_passive/Instrumentation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import time
1+
from time import perf_counter
22
from typing import Dict, Optional
33

44
from aalpy.learning_algs.general_passive.GeneralizedStateMerging import Instrumentation, Partitioning, \
@@ -29,18 +29,18 @@ def reset(self, gsm: GeneralizedStateMerging):
2929
self.nr_merged_states = 0
3030
self.nr_red_states = 0
3131

32-
self.previous_time = time.time()
32+
self.previous_time = perf_counter()
3333

3434
def pta_construction_done(self, root):
35-
print(f'PTA Construction Time: {round(time.time() - self.previous_time, 2)}')
35+
print(f'PTA Construction Time: {round(perf_counter() - self.previous_time, 2)} s')
3636
if 1 < self.lvl:
3737
states = root.get_all_nodes()
3838
leafs = [state for state in states if len(state.transitions.keys()) == 0]
3939
depth = [state.get_prefix_length() for state in leafs]
4040
self.pta_size = len(states)
4141
print(f'PTA has {len(states)} states leading to {len(leafs)} leafs')
4242
print(f'min / avg / max depth : {min(depth)} / {sum(depth) / len(depth)} / {max(depth)}')
43-
self.previous_time = time.time()
43+
self.previous_time = perf_counter()
4444

4545
def print_status(self):
4646
reset_char = "\33[2K\r"
@@ -61,7 +61,7 @@ def log_merge(self, part: Partitioning):
6161
self.print_status()
6262

6363
def learning_done(self, root: GsmNode):
64-
print(f'\nLearning Time: {round(time.time() - self.previous_time, 2)}')
64+
print(f'\nLearning Time: {round(perf_counter() - self.previous_time, 2)} s')
6565
print(f'Learned {self.nr_red_states} state automaton via {self.nr_merged_states} merges.')
6666
if 2 < self.lvl:
6767
root.visualize("model", self.gsm.output_behavior)

0 commit comments

Comments
 (0)