annotate PerfsDb/Run.py @ 178:c896ac762b9f

Added tag Orthanc-1.4.2 for changeset ef6b791c6d62
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Sep 2018 14:22:38 +0200
parents 1ff0d830bb87
children 29cb1ee97035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
1 import argparse
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
2 import fnmatch
164
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
3 import csv
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
4 import datetime
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
5 import os
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
6
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
7 from ConfigFileBuilder import ConfigFileBuilder
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
8 from TestConfig import TestConfig
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
9 from Tests import *
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
10 from DbServer import DbServer
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
11 from DbType import DbType
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
12 from DbSize import DbSize
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
13
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
14
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
15 allTestConfigs = [
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
16 TestConfig(label= "mysql-small", dbSize=DbSize.Small, dbServer=DbServer(dbType=DbType.MySQL, port=2000)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
17 TestConfig(label= "pg9-small", dbSize=DbSize.Small, dbServer=DbServer(dbType=DbType.PG9, port=2001)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
18 TestConfig(label= "pg10-small", dbSize=DbSize.Small, dbServer=DbServer(dbType=DbType.PG10, port=2002)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
19 TestConfig(label= "pg11-small", dbSize=DbSize.Small, dbServer=DbServer(dbType=DbType.PG11, port=2003)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
20 TestConfig(label= "mssql-small", dbSize=DbSize.Small, dbServer=DbServer(dbType=DbType.MSSQL, port=2004)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
21 TestConfig(label= "sqlite-small", dbSize=DbSize.Small, dbType=DbType.Sqlite),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
22 TestConfig(label= "sqliteplugin-small", dbSize=DbSize.Small, dbType=DbType.SqlitePlugin),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
23
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
24 TestConfig(label= "mysql-tiny", dbSize=DbSize.Tiny, dbServer=DbServer(dbType=DbType.MySQL, port=3000)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
25 TestConfig(label= "pg9-tiny", dbSize=DbSize.Tiny, dbServer=DbServer(dbType=DbType.PG9, port=3001)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
26 TestConfig(label= "pg10-tiny", dbSize=DbSize.Tiny, dbServer=DbServer(dbType=DbType.PG10, port=3002)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
27 TestConfig(label= "pg11-tiny", dbSize=DbSize.Tiny, dbServer=DbServer(dbType=DbType.PG11, port=3003)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
28 TestConfig(label= "mssql-tiny", dbSize=DbSize.Tiny, dbServer=DbServer(dbType=DbType.MSSQL, port=3004)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
29 TestConfig(label= "sqlite-tiny", dbSize=DbSize.Tiny, dbType=DbType.Sqlite),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
30 TestConfig(label= "sqliteplugin-tiny", dbSize=DbSize.Tiny, dbType=DbType.SqlitePlugin),
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
31
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
32 TestConfig(label= "mysql-medium", dbSize=DbSize.Medium, dbServer=DbServer(dbType=DbType.MySQL, port=4000)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
33 TestConfig(label= "pg9-medium", dbSize=DbSize.Medium, dbServer=DbServer(dbType=DbType.PG9, port=4001)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
34 TestConfig(label= "pg10-medium", dbSize=DbSize.Medium, dbServer=DbServer(dbType=DbType.PG10, port=4002)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
35 TestConfig(label= "pg11-medium", dbSize=DbSize.Medium, dbServer=DbServer(dbType=DbType.PG11, port=4003)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
36 TestConfig(label= "mssql-medium", dbSize=DbSize.Medium, dbServer=DbServer(dbType=DbType.MSSQL, port=4004)),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
37 TestConfig(label= "sqlite-medium", dbSize=DbSize.Medium, dbType=DbType.Sqlite),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
38 TestConfig(label= "sqliteplugin-medium", dbSize=DbSize.Medium, dbType=DbType.SqlitePlugin),
161
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
39
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
40 TestConfig(label= "mysql-large", dbSize=DbSize.Large, dbServer=DbServer(dbType=DbType.MySQL, port=5000)),
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
41 TestConfig(label= "pg9-large", dbSize=DbSize.Large, dbServer=DbServer(dbType=DbType.PG9, port=5001)),
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
42 TestConfig(label= "pg10-large", dbSize=DbSize.Large, dbServer=DbServer(dbType=DbType.PG10, port=5002)),
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
43 TestConfig(label= "pg11-large", dbSize=DbSize.Large, dbServer=DbServer(dbType=DbType.PG11, port=5003)),
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
44 TestConfig(label= "mssql-large", dbSize=DbSize.Large, dbServer=DbServer(dbType=DbType.MSSQL, port=5004)),
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
45 TestConfig(label= "sqlite-large", dbSize=DbSize.Large, dbType=DbType.Sqlite),
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
46 TestConfig(label= "sqliteplugin-large", dbSize=DbSize.Large, dbType=DbType.SqlitePlugin),
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
47 ]
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
48
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
49 allTests = [
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
50 TestStatistics(),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
51 TestFindStudyByStudyDescription1Result(),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
52 TestFindStudyByPatientId1Result(),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
53 TestFindStudyByStudyDescription0Results(),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
54 TestFindStudyByPatientId0Results(),
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
55 TestFindStudyByPatientId5Results(),
165
1ff0d830bb87 find 100 results
am@osimis.io
parents: 164
diff changeset
56 TestFindStudyByPatientId100Results(),
161
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
57 TestUploadNextPatientFile(),
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
58 TestUploadFirstPatientFile(),
162
dbc42a03ee75 more perfs db tests
am@osimis.io
parents: 161
diff changeset
59 TestUploadLargeFile10MB(),
dbc42a03ee75 more perfs db tests
am@osimis.io
parents: 161
diff changeset
60 TestToolsFindStudyByStudyInstanceUID(),
dbc42a03ee75 more perfs db tests
am@osimis.io
parents: 161
diff changeset
61 TestToolsFindPatientByPatientID()
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
62 ]
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
63
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
64 selectedTestConfigs = []
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
65 selectedTests = []
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
66
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
67 parser = argparse.ArgumentParser(description = "Initializes/Runs/Clears PerfsDb setup.")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
68
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
69 # create a cli option for each config
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
70 for testConfig in allTestConfigs:
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
71 parser.add_argument("--" + testConfig.label, action = "store_true")
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
72
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
73 parser.add_argument("--init", help = "initializes DBs", action = "store_true")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
74 parser.add_argument("--run", help = "runs tests", action = "store_true")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
75 parser.add_argument("--clear", help = "clear DBs", action = "store_true")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
76
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
77 parser.add_argument("--orthanc-path", help = "path to the folder containing Orthanc executable", default=".")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
78 parser.add_argument("--plugins-path", help = "path to the folder containing Orthanc executable", default=".")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
79 parser.add_argument("--repeat", help = "number of times to repeat each test to average timings", type=int, default=50)
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
80 parser.add_argument("--test-filter", help = "filter tests by names (wildcards are allowed)", default="*")
161
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
81 parser.add_argument("--verbose", help = "start Orthanc in verbose mode", action = "store_true")
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
82 parser.add_argument("--trace", help = "start Orthanc in trace mode", action = "store_true")
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
83
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
84 args = parser.parse_args()
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
85
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
86 for testConfig in allTestConfigs:
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
87 if args.__dict__[testConfig.label.replace("-", "_")]:
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
88 selectedTestConfigs.append(testConfig)
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
89
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
90 # if no test config specified, take them all
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
91 if len(selectedTestConfigs) == 0:
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
92 selectedTestConfigs = allTestConfigs
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
93
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
94 selectedTestConfigs.sort(key=lambda x: x.label)
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
95
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
96 # filter tests
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
97 for test in allTests:
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
98 if fnmatch.fnmatch(test.name, args.test_filter):
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
99 selectedTests.append(test)
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
100
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
101 selectedTests.sort(key=lambda x: x.name)
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
102
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
103 # if no action specified, it means only run
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
104 if not (args.init | args.run | args.clear):
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
105 args.init = False
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
106 args.run = True
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
107 args.clear = False
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
108
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
109 print("***** Orthanc *******")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
110 print("path :", args.orthanc_path)
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
111
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
112 results = {}
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
113
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
114 for testConfig in selectedTestConfigs:
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
115 testConfig.setRepeatCount(args.repeat)
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
116
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
117 print("======= " + testConfig.label + " ========")
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
118
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
119 if args.clear:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
120 print("** Clearing Db")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
121 testConfig.clearDb()
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
122
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
123 if args.init or args.run:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
124 print("** Generating config files")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
125 testConfig.generateOrthancConfigurationFile(args.plugins_path)
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
126
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
127 print("** Launching DbServer")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
128 testConfig.launchDbServer()
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
129
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
130 print("** Launching Orthanc")
161
27b3b0df5f90 2 upload tests
am@osimis.io
parents: 160
diff changeset
131 orthancWasAlreadyRunning = not testConfig.launchOrthanc(args.orthanc_path, verboseEnabled=args.verbose, traceEnabled=args.trace)
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
132 if orthancWasAlreadyRunning and len(selectedTestConfigs) > 1:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
133 print("Error: Can't execute multiple configuration on already running Orthanc. Exit Orthanc and let this script start Orthanc instances")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
134 exit(-1)
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
135
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
136 if args.init:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
137 testConfig.initializeDb()
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
138
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
139 if args.run:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
140 print("** Runnnig tests")
160
6995d5d12d88 filtering tests
am@osimis.io
parents: 158
diff changeset
141 results[testConfig.label] = testConfig.runTests(selectedTests)
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
142
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
143 print("** Stopping Orthanc")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
144 testConfig.stopOrthanc()
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
145
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
146 print("++++++++++++++ results summary +++++++++++++++")
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
147 testNames = set()
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
148 resultsByTestName = {}
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
149 for configName, configResult in results.items():
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
150 for result in configResult:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
151 testNames.add(result.name)
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
152 if not result.name in resultsByTestName:
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
153 resultsByTestName[result.name] = {}
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
154 resultsByTestName[result.name][configName] = result
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
155
164
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
156 resultFileName = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Results/run-" + datetime.datetime.now().strftime("%Y.%m.%d.%H.%M.%S"))
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
157
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
158 with open(resultFileName, 'w', newline='') as resultFile:
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
159 resultWriter = csv.writer(resultFile)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
160 resultHeaderRow = [""]
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
161
164
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
162 headerLine = "{empty:<40}|".format(empty="")
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
163
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
164 for testConfig in selectedTestConfigs:
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
165 headerLine += "{configName:^15}|".format(configName=testConfig.label)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
166 resultHeaderRow.append(configName)
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
167
164
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
168 print(headerLine)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
169 resultWriter.writerow(resultHeaderRow)
158
df1f9946571c perfs db continued: tests working with tiny DBs on all setup but the sqliteplugin
am@osimis.io
parents:
diff changeset
170
164
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
171 for testName in sorted(testNames):
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
172 resultLine = "{name:<40}|".format(name=testName)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
173 resultRow=[testName]
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
174
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
175 for testConfig in selectedTestConfigs:
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
176 resultLine += "{avg:>11.2f} ms |".format(avg = resultsByTestName[testName][testConfig.label].averageTimeInMs)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
177 resultRow.append(resultsByTestName[testName][testConfig.label].averageTimeInMs)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
178
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
179 print(resultLine)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
180 resultWriter.writerow(resultRow)
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
181
ff939d07989f saving results
am@osimis.io
parents: 162
diff changeset
182 print("** Done; results saved in " + resultFileName)