1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 """
19 Contains the Monitoring class.
20
21 The monitoring functions comes into action if the flag DEBUG_ENABLED,
22 in the :doc:`timelinelib module <timelinelib>`, is set to True.
23 This happens if the application argument --debug is used at start of Timeline.
24 When DEBUG_ENABLED is True, timer and counting statistics are shown
25 in the main panel.
26
27 :doc:`Tests are found here <unit_monitoring>`.
28 """
29
30 from timelinelib.timer import Timer
34 """
35 * Kepp track of the number of times the timeline has been redrawn.
36 * Measure the time it takes to redraw.
37 """
39 self._timeline_redraw_count = 0
40 self._category_redraw_count = 0
41 if timer is None:
42 self._timer = Timer()
43 else:
44 self._timer = timer
45
47 """Increment counter."""
48 self._timeline_redraw_count += 1
49
51 """Increment counter."""
52 self._category_redraw_count += 1
53
55 """Start time measurement."""
56 self._timer.start()
57
59 """Stop time measurement."""
60 self._timer.end()
61
62 @property
64 """Return the elapsed time in milliseconds."""
65 return self._timer.elapsed_ms
66