# HG changeset patch # User am@osimis.io # Date 1534769672 -7200 # Node ID 53575aa2614bad302b3c5ca6a0740e91f2d42198 # Parent dbc42a03ee75cef7f57d182f9dfc0b22e4a96f60 added stats during db creation diff -r dbc42a03ee75 -r 53575aa2614b .hgignore --- 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 diff -r dbc42a03ee75 -r 53575aa2614b PerfsDb/ConfigFiles/.hgkeep diff -r dbc42a03ee75 -r 53575aa2614b PerfsDb/DbPopulator.py --- 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)) diff -r dbc42a03ee75 -r 53575aa2614b PerfsDb/Results/.hgkeep diff -r dbc42a03ee75 -r 53575aa2614b PerfsDb/Storages/.hgkeep diff -r dbc42a03ee75 -r 53575aa2614b PerfsDb/TestConfig.py --- 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]: