Mercurial > hg > orthanc-tests
changeset 163:53575aa2614b
added stats during db creation
author | am@osimis.io |
---|---|
date | Mon, 20 Aug 2018 14:54:32 +0200 |
parents | dbc42a03ee75 |
children | ff939d07989f |
files | .hgignore PerfsDb/ConfigFiles/.hgkeep PerfsDb/DbPopulator.py PerfsDb/Results/.hgkeep PerfsDb/Storages/.hgkeep PerfsDb/TestConfig.py |
diffstat | 3 files changed, 37 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Mon Aug 20 14:23:54 2018 +0200 +++ b/.hgignore Mon Aug 20 14:54:32 2018 +0200 @@ -5,4 +5,5 @@ PerfsDb/.env/ PerfsDb/Storages/ PerfsDb/ConfigFiles/ +PerfsDb/Results/ .vscode/ \ No newline at end of file
--- a/PerfsDb/DbPopulator.py Mon Aug 20 14:23:54 2018 +0200 +++ b/PerfsDb/DbPopulator.py Mon Aug 20 14:54:32 2018 +0200 @@ -1,5 +1,7 @@ import typing import time +import csv +import os from orthancRestApi import OrthancClient from TestResult import TestResult from DbSize import DbSize @@ -12,7 +14,7 @@ self._sourceInstanceId = None self._fileCounter = 0 - def populate(self): + def populate(self, label: str): self._sourceInstanceId = self._orthanc.uploadDicomFile("../Database/DummyCT.dcm") if self._dbSize == DbSize.Tiny: @@ -70,18 +72,38 @@ # used in TestToolsFindStudyByStudyInstanceUID self.createStudy(studyIndex=99999, patientIndex=99999, seriesCount=1, instancesPerSeries=1) - # then, add data to make the DB "large" or "small" - for patientIndex in range(0, patientCount): - studyIndex=0 - print("Generating data for patient " + str(patientIndex)) - for i in range(0, smallStudiesPerPatient): - print("Generating small study " + str(i)) - self.createStudy(studyIndex=studyIndex, patientIndex=patientIndex, seriesCount=seriesPerSmallStudy, instancesPerSeries=instancesPerSmallSeries) - studyIndex+=1 - for i in range(0, largeStudiesPerPatient): - print("Generating large study " + str(i)) - self.createStudy(studyIndex=studyIndex, patientIndex=patientIndex, seriesCount=seriesPerLargeStudy, instancesPerSeries=instancesPerLargeSeries) - studyIndex+=1 + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "Results/db-init-" + label), 'w', newline='') as resultFile: + resultWriter = csv.writer(resultFile) + resultWriter.writerow(["patientCount", "filesCount", "duration", "files/sec"]) + # then, add data to make the DB "large" or "small" + for patientIndex in range(0, patientCount): + studyIndex=0 + print("Generating data for patient " + str(patientIndex)) + fileCounterAtPatientStart = self._fileCounter + startTimePatient = time.time() + + for i in range(0, smallStudiesPerPatient): + print("Generating small study " + str(i)) + self.createStudy(studyIndex=studyIndex, patientIndex=patientIndex, seriesCount=seriesPerSmallStudy, instancesPerSeries=instancesPerSmallSeries) + studyIndex+=1 + for i in range(0, largeStudiesPerPatient): + print("Generating large study " + str(i)) + self.createStudy(studyIndex=studyIndex, patientIndex=patientIndex, seriesCount=seriesPerLargeStudy, instancesPerSeries=instancesPerLargeSeries) + studyIndex+=1 + + endTimePatient = time.time() + print("STATS: uploaded {n} files in {s:.2f} seconds; {x:.2f} files/sec".format( + n=self._fileCounter - fileCounterAtPatientStart, + s=endTimePatient - startTimePatient, + x=(self._fileCounter - fileCounterAtPatientStart)/(endTimePatient - startTimePatient) + )) + resultWriter.writerow([ + patientIndex, + self._fileCounter - fileCounterAtPatientStart, + endTimePatient - startTimePatient, + (self._fileCounter - fileCounterAtPatientStart)/(endTimePatient - startTimePatient) + ]) + resultFile.flush() endTime = time.time() print("Generation completed. Elapsed time: {duration:.2f} sec".format(duration=endTime-startTime))
--- a/PerfsDb/TestConfig.py Mon Aug 20 14:23:54 2018 +0200 +++ b/PerfsDb/TestConfig.py Mon Aug 20 14:54:32 2018 +0200 @@ -74,7 +74,7 @@ def initializeDb(self): dbPopulator = DbPopulator(orthanc=OrthancClient("http://127.0.0.1:8042"), dbSize=self._dbSize) - dbPopulator.populate() + dbPopulator.populate(self.label) def runTests(self, tests: typing.List[Test]) -> typing.List[TestResult]: