Package Gnumed :: Package timelinelib :: Module monitoring
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.monitoring

 1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # Timeline is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
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 
31 32 33 -class Monitoring(object):
34 """ 35 * Kepp track of the number of times the timeline has been redrawn. 36 * Measure the time it takes to redraw. 37 """
38 - def __init__(self, timer=None):
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
46 - def count_timeline_redraw(self):
47 """Increment counter.""" 48 self._timeline_redraw_count += 1
49
50 - def count_category_redraw(self):
51 """Increment counter.""" 52 self._category_redraw_count += 1
53
54 - def timer_start(self):
55 """Start time measurement.""" 56 self._timer.start()
57
58 - def timer_end(self):
59 """Stop time measurement.""" 60 self._timer.end()
61 62 @property
63 - def timer_elapsed_ms(self):
64 """Return the elapsed time in milliseconds.""" 65 return self._timer.elapsed_ms
66