comparison PerfsDb/Test.py @ 158:df1f9946571c

perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
author am@osimis.io
date Fri, 17 Aug 2018 11:58:26 +0200
parents f1a75985caa8
children 27b3b0df5f90
comparison
equal deleted inserted replaced
157:ac14100ffbd7 158:df1f9946571c
15 self._orthanc = orthanc 15 self._orthanc = orthanc
16 16
17 def setRepeatCount(self, repeatCount: int): 17 def setRepeatCount(self, repeatCount: int):
18 self.repeatCount = repeatCount 18 self.repeatCount = repeatCount
19 19
20 def prepare(self): 20 def beforeAll(self):
21 """ 21 """
22 Code to execute before the execution of a test; i.e: upload a file (not including in timings) 22 Code to execute before the execution of all repetitions of a test; i.e: upload a file.
23 This code is not included in timings
24 """
25 pass
26
27 def beforeEach(self):
28 """
29 Code to execute before the execution of each repetition of a test.
30 This code is not included in timings
23 """ 31 """
24 pass 32 pass
25 33
26 def test(self): 34 def test(self):
27 """ 35 """
28 Code whose execution time will be measured 36 Code whose execution time will be measured
29 """ 37 """
30 pass 38 pass
31 39
32 def cleanup(self): 40 def afterEach(self):
33 """ 41 """
34 Code to execute after the execution of a test; i.e: remove an instance (not including in timings) 42 Code to execute after the execution of each repetition of a test.
43 This code is not included in timings
44 """
45 pass
46
47 def afterAll(self):
48 """
49 Code to execute after the execution of all repetitions of a test.
50 This code is not included in timings
35 """ 51 """
36 pass 52 pass
37 53
38 def run(self) -> TestResult: 54 def run(self) -> TestResult:
39 result = TestResult(self.name) 55 result = TestResult(self.name)
40 56
57 self.beforeAll()
58
41 for i in range(0, self.repeatCount): 59 for i in range(0, self.repeatCount):
42 self.prepare() 60 self.beforeEach()
43 startTime = time.time() 61 startTime = time.time()
44 self.test() 62 self.test()
45 endTime = time.time() 63 endTime = time.time()
46 self.cleanup() 64 self.afterEach()
47 65
48 result.add((endTime - startTime) * 1000) 66 result.add((endTime - startTime) * 1000)
49 67
68 self.afterAll()
50 result.compute() 69 result.compute()
51 return result 70 return result
52 71
53 def __str__(self): 72 def __str__(self):
54 return "{name:<40}: {avg:>8.2f} ms {min:>8.2f} ms {max:>8.2f} ms".format( 73 return "{name:<40}: {avg:>8.2f} ms {min:>8.2f} ms {max:>8.2f} ms".format(