Mercurial > hg > orthanc-tests
comparison PerfsDb/TestResult.py @ 169:85a2074f8794
measuring orthanc startup time
author | am@osimis.io |
---|---|
date | Fri, 31 Aug 2018 11:01:40 +0200 |
parents | f1a75985caa8 |
children |
comparison
equal
deleted
inserted
replaced
168:11b7e1fa7aff | 169:85a2074f8794 |
---|---|
14 def add(self, durationInMs: float): | 14 def add(self, durationInMs: float): |
15 self._durations.append(durationInMs) | 15 self._durations.append(durationInMs) |
16 | 16 |
17 def compute(self): | 17 def compute(self): |
18 | 18 |
19 mean = statistics.mean(self._durations) | 19 if len(self._durations) >= 2: |
20 stdDev = statistics.stdev(self._durations) | 20 mean = statistics.mean(self._durations) |
21 stdDev = statistics.stdev(self._durations) | |
21 | 22 |
22 # remove outliers | 23 # remove outliers |
23 cleanedDurations = [x for x in self._durations if (x > mean - 2*stdDev) and (x < mean + 2*stdDev)] | 24 cleanedDurations = [x for x in self._durations if (x > mean - 2*stdDev) and (x < mean + 2*stdDev)] |
24 | 25 |
25 self.averageTimeInMs = statistics.mean(cleanedDurations) | 26 self.averageTimeInMs = statistics.mean(cleanedDurations) |
26 self.minTimeInMs = min(cleanedDurations) | 27 self.minTimeInMs = min(cleanedDurations) |
27 self.maxTimeInMs = max(cleanedDurations) | 28 self.maxTimeInMs = max(cleanedDurations) |
29 elif len(self._durations) == 1: | |
30 self.averageTimeInMs = self._durations[0] | |
31 self.minTimeInMs = self._durations[0] | |
32 self.maxTimeInMs = self._durations[0] | |
33 else: | |
34 raise ArithmeticError # you need at least one measure ! | |
28 | 35 |
36 | |
29 | 37 |
30 def __str__(self): | 38 def __str__(self): |
31 return "{name:<40}: {avg:>8.2f} ms {min:>8.2f} ms {max:>8.2f} ms".format( | 39 return "{name:<40}: {avg:>8.2f} ms {min:>8.2f} ms {max:>8.2f} ms".format( |
32 name=self.name, | 40 name=self.name, |
33 avg = self.averageTimeInMs, | 41 avg = self.averageTimeInMs, |