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  """Contains the Monitoring class."""
    19
    20  from timelinelib.timer import Timer
    21
    22
    23 -class Monitoring(object):
    24      """
    25      * Kepp track of the number of times the timeline has been redrawn.
    26      * Measure the time it takes to redraw.
    27      """
    28 -    def __init__(self, timer=None):
    29          self._timeline_redraw_count = 0
    30          self._category_redraw_count = 0
    31          if timer is None:
    32              self._timer = Timer()
    33          else:
    34              self._timer = timer
    35
    36 -    def count_timeline_redraw(self):
    37          """Increment counter."""
    38          self._timeline_redraw_count += 1
    39
    40 -    def count_category_redraw(self):
    41          """Increment counter."""
    42          self._category_redraw_count += 1
    43
    44 -    def timer_start(self):
    45          """Start time measurement."""
    46          self._timer.start()
    47
    48 -    def timer_end(self):
    49          """Stop time measurement."""
    50          self._timer.end()
    51
    52      @property
    53 -    def timer_elapsed_ms(self):
    54          "return the elapsed time in milliseconds."
    55          return self._timer.elapsed_ms
    56