changeset 164:ff939d07989f

saving results
author am@osimis.io
date Mon, 20 Aug 2018 15:50:47 +0200
parents 53575aa2614b
children 1ff0d830bb87
files PerfsDb/README.md PerfsDb/Run.py PerfsDb/Test.py PerfsDb/TestConfig.py
diffstat 4 files changed, 43 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/PerfsDb/README.md	Mon Aug 20 14:54:32 2018 +0200
+++ b/PerfsDb/README.md	Mon Aug 20 15:50:47 2018 +0200
@@ -23,6 +23,7 @@
 -------------
 
 - install standard tools
+
 ```bash
 sudo apt-get install -y mercurial wget curl
 ```
@@ -77,9 +78,19 @@
 
 ```
 
-Filtering tests
----------------
+Command line options
+--------------------
+
 ```bash
-python Run.py --orthanc-path=/.../ --plugins-path=/.../ --run --pg9-tiny test-filter=*ByPatient*
+--clear                          to clear the DB
+--init                           to initialize the DB
+--run                            to run the tests
+
+--config                         to include the config in the test run/init/clear
 
+--orthanc-path                   path to the folder where the Orthanc execuble lies
+--plugins-path                   path to the folder where the Orthanc plugins lie
+
+--test-filter=*ByPatient*        to filter the tests to execute
+--repeat=20                      to repeate each test N times (default is 20)
 ```
\ No newline at end of file
--- a/PerfsDb/Run.py	Mon Aug 20 14:54:32 2018 +0200
+++ b/PerfsDb/Run.py	Mon Aug 20 15:50:47 2018 +0200
@@ -1,5 +1,8 @@
 import argparse
 import fnmatch
+import csv
+import datetime
+import os
 
 from ConfigFileBuilder import ConfigFileBuilder
 from TestConfig import TestConfig
@@ -149,16 +152,30 @@
             resultsByTestName[result.name] = {}
         resultsByTestName[result.name][configName] = result
 
-headerLine = "{empty:<40}|".format(empty="")
-for testConfig in selectedTestConfigs:
-    headerLine += "{configName:^15}|".format(configName=testConfig.label)
+resultFileName = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Results/run-" + datetime.datetime.now().strftime("%Y.%m.%d.%H.%M.%S"))
+
+with open(resultFileName, 'w', newline='') as resultFile:
+    resultWriter = csv.writer(resultFile)
+    resultHeaderRow = [""]
 
-print(headerLine)
+    headerLine = "{empty:<40}|".format(empty="")
+
+    for testConfig in selectedTestConfigs:
+        headerLine += "{configName:^15}|".format(configName=testConfig.label)
+        resultHeaderRow.append(configName)
 
-for testName in sorted(testNames):
-    resultLine = "{name:<40}|".format(name=testName)
-    for testConfig in selectedTestConfigs:
-        resultLine += "{avg:>11.2f} ms |".format(avg = resultsByTestName[testName][testConfig.label].averageTimeInMs)
-    print(resultLine)
+    print(headerLine)
+    resultWriter.writerow(resultHeaderRow)
 
-print("** Done")
+    for testName in sorted(testNames):
+        resultLine = "{name:<40}|".format(name=testName)
+        resultRow=[testName]
+        
+        for testConfig in selectedTestConfigs:
+            resultLine += "{avg:>11.2f} ms |".format(avg = resultsByTestName[testName][testConfig.label].averageTimeInMs)
+            resultRow.append(resultsByTestName[testName][testConfig.label].averageTimeInMs)
+        
+        print(resultLine)
+        resultWriter.writerow(resultRow)
+
+print("** Done; results saved in " + resultFileName)
--- a/PerfsDb/Test.py	Mon Aug 20 14:54:32 2018 +0200
+++ b/PerfsDb/Test.py	Mon Aug 20 15:50:47 2018 +0200
@@ -9,7 +9,7 @@
     def __init__(self, name: str):
         self.name = name
         self._orthanc = None
-        self.repeatCount = 10
+        self.repeatCount = 20
         
     def setOrthancClient(self, orthanc: OrthancClient):
         self._orthanc = orthanc
--- a/PerfsDb/TestConfig.py	Mon Aug 20 14:54:32 2018 +0200
+++ b/PerfsDb/TestConfig.py	Mon Aug 20 15:50:47 2018 +0200
@@ -26,7 +26,7 @@
         self.label = label
         self._port = None
         self._orthancProcess = None
-        self._repeatCount = 10
+        self._repeatCount = 20
 
         if dbServer is not None:
             self._dbType = dbServer.dbType