Public Member Functions | Public Attributes | List of all members
SortModuleTimes.TimeModuleStatsClass Class Reference
Inheritance diagram for SortModuleTimes.TimeModuleStatsClass:
SortModuleTimes.Stats

Public Member Functions

def __init__ (self, moduleKey, bTrackEntries=False)
 
def add (self, data)
 
def complete (self, eventKeys)
 
def getEvents (self)
 
def getEntries (self)
 
def nEntries (self)
 
def nEvents (self)
 
def hasEmptyData (self)
 
def FormatStatsAsList (self, format_=None)
 
def FormatTimesAsList (self, format_={})
 
- Public Member Functions inherited from SortModuleTimes.Stats
def __init__ (self, bFloat=True)
 
def clear (self, bFloat=True)
 
def add (self, value, weight=1)
 
def n (self)
 
def weights (self)
 
def sum (self)
 
def min (self)
 
def max (self)
 
def sumsq (self)
 
def average (self)
 
def sqaverage (self)
 
def rms2 (self)
 
def rms (self)
 
def stdev (self)
 
def stdevp (self)
 

Public Attributes

 key
 
 entries
 
- Public Attributes inherited from SortModuleTimes.Stats
 e_n
 
 e_w
 
 e_sum
 
 e_sumsq
 
 e_min
 
 e_max
 

Detailed Description

Collects statistics about execution time.

This class collects statistics about execution time of a module or the whole
event.
The timing information is added by add() function, with as argument an
instance of EntryDataClass.
Optionally, the object can keep track of all the entries separately.
The order of insertion of the events is also recorded.
By default, this does not happen and only statistics are stored.

The sample can be forcibly filled with empty entries. The idea is that one
event is added to the sample only when the information about its timing is
available. If we are tracking the event keys, we can check if we have all
the events and, if some event keys are missing, we can add an empty entry for
them so that we have the correct number of enrties in the sample.
This is achieved by a call to complete().
Note that to keep the order of the events the correct one one should check
if the previous event is present or not, and complete() with it, before
adding a new event. If the completion is performed after the new event is
added, the previous event will be added after the new one, when complete()
is actually called.

Definition at line 196 of file SortModuleTimes.py.

Constructor & Destructor Documentation

def SortModuleTimes.TimeModuleStatsClass.__init__ (   self,
  moduleKey,
  bTrackEntries = False 
)
Constructor: specifies the module we collect information about.

If the flag bTrackEntries is true, all the added events are stored singly.

Definition at line 219 of file SortModuleTimes.py.

219  def __init__(self, moduleKey, bTrackEntries = False):
220  """Constructor: specifies the module we collect information about.
221 
222  If the flag bTrackEntries is true, all the added events are stored singly.
223  """
224  Stats.__init__(self)
225  self.key = moduleKey
226  self.entries = OrderedDict() if bTrackEntries else None
def __init__(self, moduleKey, bTrackEntries=False)

Member Function Documentation

def SortModuleTimes.TimeModuleStatsClass.add (   self,
  data 
)
Adds a time to the sample.

The argument data is an instance of EntryDataClass, that includes both
event identification and timing information.
Its time() is used as the value of the statistic; if the entry has no time
(None), the event information is considered to be missing.

Definition at line 229 of file SortModuleTimes.py.

229  def add(self, data):
230  """Adds a time to the sample.
231 
232  The argument data is an instance of EntryDataClass, that includes both
233  event identification and timing information.
234  Its time() is used as the value of the statistic; if the entry has no time
235  (None), the event information is considered to be missing.
236  """
237  if self.entries is not None:
238  if data.eventKey in self.entries: return False
239  self.entries[data.eventKey] = data
240  # if
241  if not data.isMissing(): Stats.add(self, data.time())
242  return True
def SortModuleTimes.TimeModuleStatsClass.complete (   self,
  eventKeys 
)
Makes sure that an entry for each of the keys in eventKeys is present.

For event keys already known, nothing happens. For new event keys, an
empty entry is added at the end of the list, with no time information.
Note that the events are added at the bottom of the list, in the relative
order in eventKeys.

If we are not tracking the events, nothing happens ever.

Definition at line 245 of file SortModuleTimes.py.

245  def complete(self, eventKeys):
246  """Makes sure that an entry for each of the keys in eventKeys is present.
247 
248  For event keys already known, nothing happens. For new event keys, an
249  empty entry is added at the end of the list, with no time information.
250  Note that the events are added at the bottom of the list, in the relative
251  order in eventKeys.
252 
253  If we are not tracking the events, nothing happens ever.
254  """
255  if self.entries is None: return 0
256  if (len(self.entries) > 1): eventKeys = eventKeys[-1:]
257  res = 0
258  for eventKey in eventKeys:
259  if self.add(EntryDataClass(eventKey)): res += 1
260  return res
def add(self, value, weight=1)
def SortModuleTimes.TimeModuleStatsClass.FormatStatsAsList (   self,
  format_ = None 
)
Prints the collected information into a list.

The list of strings includes a statistics ID (based on the key), an
average time, a relative RMS in percent, the total time and the recorded
the number of events with timing information and the timing extrema.

The format dictionary can contain format directives, for future use (no
format directive is currently supported).

Definition at line 291 of file SortModuleTimes.py.

291  def FormatStatsAsList(self, format_ = None):
292  """Prints the collected information into a list.
293 
294  The list of strings includes a statistics ID (based on the key), an
295  average time, a relative RMS in percent, the total time and the recorded
296  the number of events with timing information and the timing extrema.
297 
298  The format dictionary can contain format directives, for future use (no
299  format directive is currently supported).
300  """
301  if isinstance(self.key, basestring): name = str(self.key)
302  else: name = str(self.key)
303  if (self.n() == 0) or (self.sum() == 0.):
304  return [ name, "n/a" ]
305  RMS = self.rms() if (self.n() != 0) else 0.
306  return [
307  name,
308  "%g\"" % self.average(),
309  "(RMS %4.1f%%)" % (RMS / self.average() * 100.),
310  "total %g\"" % self.sum(), "(%d events:" % self.n(),
311  "%g" % self.min(), "- %g)" % self.max(),
312  ]
def FormatStatsAsList(self, format_=None)
static QCString str
def SortModuleTimes.TimeModuleStatsClass.FormatTimesAsList (   self,
  format_ = {} 
)
Prints the collected information into a list.

The list of strings includes a statistics ID (based on the key), and
a time entry for each of the events stored (with holes for the events
with missing time).
The format dictionary can contain format directives; the ones supported
so far are:
- 'max_events' (int): limit the number of events to the first max_events
  (by default, all the available entries are printed)
- 'format' (string, default: '%g'): the C-style formatting string for the
  numeric timings

Definition at line 315 of file SortModuleTimes.py.

315  def FormatTimesAsList(self, format_ = {}):
316  """Prints the collected information into a list.
317 
318  The list of strings includes a statistics ID (based on the key), and
319  a time entry for each of the events stored (with holes for the events
320  with missing time).
321  The format dictionary can contain format directives; the ones supported
322  so far are:
323  - 'max_events' (int): limit the number of events to the first max_events
324  (by default, all the available entries are printed)
325  - 'format' (string, default: '%g'): the C-style formatting string for the
326  numeric timings
327  """
328  if isinstance(self.key, basestring): name = str(self.key)
329  else: name = str(self.key)
330 
331  n = min(self.nEntries(), format_.get('max_events', self.nEntries()))
332  format_str = format_.get('format', '%g')
333  if not self.entries: return [ name, ] + [ "n/a", ] * n
334 
335  output = [ name, ]
336  for i, entry in enumerate(self.entries.values()):
337  if i >= n: break
338  if entry is None or entry.isMissing(): output.append("n/a")
339  else: output.append(format_str % entry.time())
340  # for
341  return output
auto enumerate(Iterables &&...iterables)
Range-for loop helper tracking the number of iteration.
Definition: enumerate.h:69
def FormatTimesAsList(self, format_={})
static QCString str
def SortModuleTimes.TimeModuleStatsClass.getEntries (   self)
Returns a list of the event statistics (if tracking the events).

Definition at line 268 of file SortModuleTimes.py.

268  def getEntries(self):
269  """Returns a list of the event statistics (if tracking the events)."""
270  return [] if self.entries is None else self.entries.values()
def SortModuleTimes.TimeModuleStatsClass.getEvents (   self)
Returns the list of known event keys (if tracking the events).

Definition at line 263 of file SortModuleTimes.py.

263  def getEvents(self):
264  """Returns the list of known event keys (if tracking the events)."""
265  return [] if self.entries is None else self.entries.keys()
def SortModuleTimes.TimeModuleStatsClass.hasEmptyData (   self)
Returns whethere there are entries without timing information.

Note: throws if not tracking events.

Definition at line 283 of file SortModuleTimes.py.

283  def hasEmptyData(self):
284  """Returns whethere there are entries without timing information.
285 
286  Note: throws if not tracking events.
287  """
288  return self.nEntries() > self.nEvents()
def SortModuleTimes.TimeModuleStatsClass.nEntries (   self)
Returns the number of recorded entries (throws if not tracking).

Definition at line 273 of file SortModuleTimes.py.

273  def nEntries(self):
274  """Returns the number of recorded entries (throws if not tracking)."""
275  return len(self.entries)
def SortModuleTimes.TimeModuleStatsClass.nEvents (   self)
Returns the number of valid entries (events with timing).

Definition at line 278 of file SortModuleTimes.py.

278  def nEvents(self):
279  """Returns the number of valid entries (events with timing)."""
280  return self.n()

Member Data Documentation

SortModuleTimes.TimeModuleStatsClass.entries

Definition at line 226 of file SortModuleTimes.py.

SortModuleTimes.TimeModuleStatsClass.key

Definition at line 225 of file SortModuleTimes.py.


The documentation for this class was generated from the following file: