# HG changeset patch # User am@osimis.io # Date 1535706100 -7200 # Node ID 85a2074f8794ebccda0cd4815e6719992ae188ab # Parent 11b7e1fa7affd1e4823d3fee1a625d844184c884 measuring orthanc startup time diff -r 11b7e1fa7aff -r 85a2074f8794 PerfsDb/TestConfig.py --- a/PerfsDb/TestConfig.py Fri Aug 31 10:35:09 2018 +0200 +++ b/PerfsDb/TestConfig.py Fri Aug 31 11:01:40 2018 +0200 @@ -2,6 +2,8 @@ import subprocess import os import shutil +import time +from osimis_timer import TimeOut from orthancRestApi import OrthancClient from DbSize import DbSize @@ -27,6 +29,7 @@ self._port = None self._orthancProcess = None self._repeatCount = 20 + self._results = [] if dbServer is not None: self._dbType = dbServer.dbType @@ -60,10 +63,20 @@ elif verboseEnabled: runOrthancCommand.append("--verbose") + startupTimeResult = TestResult("Startup time") + startTime = time.time() + self._orthancProcess = subprocess.Popen(runOrthancCommand) print("Waiting for Orthanc to start") - orthanc.waitStarted(timeout=30) + if not TimeOut.waitUntilCondition(lambda: orthanc.isAlive(), 3000, evaluateInterval = 0.1): + print("Orthanc failed to start") + exit(-2) + endTime = time.time() + + startupTimeResult.add((endTime - startTime) * 1000) + startupTimeResult.compute() + self._results.append(startupTimeResult) print("Orthanc has started") return True @@ -78,15 +91,14 @@ def runTests(self, tests: typing.List[Test]) -> typing.List[TestResult]: - results = [] for test in tests: test.setOrthancClient(OrthancClient("http://127.0.0.1:8042")) test.setRepeatCount(self._repeatCount) result = test.run() print(str(result)) - results.append(result) - return results + self._results.append(result) + return self._results def clearDb(self): if self._dbServer is not None: diff -r 11b7e1fa7aff -r 85a2074f8794 PerfsDb/TestResult.py --- a/PerfsDb/TestResult.py Fri Aug 31 10:35:09 2018 +0200 +++ b/PerfsDb/TestResult.py Fri Aug 31 11:01:40 2018 +0200 @@ -16,16 +16,24 @@ def compute(self): - mean = statistics.mean(self._durations) - stdDev = statistics.stdev(self._durations) + if len(self._durations) >= 2: + mean = statistics.mean(self._durations) + stdDev = statistics.stdev(self._durations) - # remove outliers - cleanedDurations = [x for x in self._durations if (x > mean - 2*stdDev) and (x < mean + 2*stdDev)] - - self.averageTimeInMs = statistics.mean(cleanedDurations) - self.minTimeInMs = min(cleanedDurations) - self.maxTimeInMs = max(cleanedDurations) + # remove outliers + cleanedDurations = [x for x in self._durations if (x > mean - 2*stdDev) and (x < mean + 2*stdDev)] + + self.averageTimeInMs = statistics.mean(cleanedDurations) + self.minTimeInMs = min(cleanedDurations) + self.maxTimeInMs = max(cleanedDurations) + elif len(self._durations) == 1: + self.averageTimeInMs = self._durations[0] + self.minTimeInMs = self._durations[0] + self.maxTimeInMs = self._durations[0] + else: + raise ArithmeticError # you need at least one measure ! + def __str__(self): return "{name:<40}: {avg:>8.2f} ms {min:>8.2f} ms {max:>8.2f} ms".format(