def get_latencies(self):
"""Return a dict, indexed by category, that contains a dict of
latency numbers for each category. Each dict will contain the
- following keys: mean, median, 90_percentile, 95_percentile,
- 99_percentile). If no samples have been collected for the given
- category, then that category name will not be present in the return
- value."""
+ following keys: mean, median, 1_percentile, 10_percentile,
+ 90_percentile, 95_percentile, 99_percentile, 999_percentile. If no
+ samples have been collected for the given category, then that
+ category name will not be present in the return value."""
# note that Amazon's Dynamo paper says they use 99.9% percentile.
output = {}
for category in self.latencies:
samples.sort()
count = len(samples)
stats["mean"] = sum(samples) / count
+ stats["1_percentile"] = samples[int(0.01 * count)]
+ stats["10_percentile"] = samples[int(0.1 * count)]
stats["median"] = samples[int(0.5 * count)]
stats["90_percentile"] = samples[int(0.9 * count)]
stats["95_percentile"] = samples[int(0.95 * count)]