Warning

This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy.job_metrics.collectl.stats

""" Primitive module for tracking running statistics without storing values in
memory.
"""


[docs]class StatisticsTracker:
[docs] def __init__(self): self.min = None self.max = None self.count = 0 self.sum = 0
[docs] def track(self, value): if self.min is None or value < self.min: self.min = value if self.max is None or value > self.max: self.max = value self.count += 1 self.sum += value
@property def avg(self): if self.count > 0: return self.sum / self.count else: return None