comparison PerfsDb/DbPopulator.py @ 165:1ff0d830bb87

find 100 results
author am@osimis.io
date Tue, 21 Aug 2018 15:20:45 +0200
parents 53575aa2614b
children
comparison
equal deleted inserted replaced
164:ff939d07989f 165:1ff0d830bb87
58 print("{n:>12} instances".format(n=patientCount * (smallStudiesPerPatient * seriesPerSmallStudy * instancesPerSmallSeries + largeStudiesPerPatient * seriesPerLargeStudy * instancesPerLargeSeries))) 58 print("{n:>12} instances".format(n=patientCount * (smallStudiesPerPatient * seriesPerSmallStudy * instancesPerSmallSeries + largeStudiesPerPatient * seriesPerLargeStudy * instancesPerLargeSeries)))
59 59
60 startTime = time.time() 60 startTime = time.time()
61 # first add data that are the same in small and large DBs (and that can be used in tests for comparing the same things !!) 61 # first add data that are the same in small and large DBs (and that can be used in tests for comparing the same things !!)
62 62
63 # used in TestFindStudyByPatientId100Results
64 for i in range(100):
65 self.createStudy(studyIndex=199000+i, patientIndex=99997, seriesCount=1, instancesPerSeries=1)
66
63 # used in TestFindStudyByPatientId5Results 67 # used in TestFindStudyByPatientId5Results
64 self.createStudy(studyIndex=99994, patientIndex=99998, seriesCount=1, instancesPerSeries=1) 68 self.createStudy(studyIndex=99994, patientIndex=99998, seriesCount=1, instancesPerSeries=1)
65 self.createStudy(studyIndex=99995, patientIndex=99998, seriesCount=1, instancesPerSeries=1) 69 self.createStudy(studyIndex=99995, patientIndex=99998, seriesCount=1, instancesPerSeries=1)
66 self.createStudy(studyIndex=99996, patientIndex=99998, seriesCount=1, instancesPerSeries=1) 70 self.createStudy(studyIndex=99996, patientIndex=99998, seriesCount=1, instancesPerSeries=1)
67 self.createStudy(studyIndex=99997, patientIndex=99998, seriesCount=1, instancesPerSeries=1) 71 self.createStudy(studyIndex=99997, patientIndex=99998, seriesCount=1, instancesPerSeries=1)
70 # used in TestFindStudyByStudyDescription1Result 74 # used in TestFindStudyByStudyDescription1Result
71 # used in TestFindStudyByPatientId1Result 75 # used in TestFindStudyByPatientId1Result
72 # used in TestToolsFindStudyByStudyInstanceUID 76 # used in TestToolsFindStudyByStudyInstanceUID
73 self.createStudy(studyIndex=99999, patientIndex=99999, seriesCount=1, instancesPerSeries=1) 77 self.createStudy(studyIndex=99999, patientIndex=99999, seriesCount=1, instancesPerSeries=1)
74 78
75 with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "Results/db-init-" + label), 'w', newline='') as resultFile: 79 with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "Results/db-init-" + label + ".csv"), 'w', newline='') as resultFile:
76 resultWriter = csv.writer(resultFile) 80 resultWriter = csv.writer(resultFile)
77 resultWriter.writerow(["patientCount", "filesCount", "duration", "files/sec"]) 81 resultWriter.writerow(["#patientCount", "filesCount", "files/sec"])
78 # then, add data to make the DB "large" or "small" 82 # then, add data to make the DB "large" or "small"
79 for patientIndex in range(0, patientCount): 83 for patientIndex in range(0, patientCount):
80 studyIndex=0 84 studyIndex=0
81 print("Generating data for patient " + str(patientIndex)) 85 print("Generating data for patient " + str(patientIndex))
82 fileCounterAtPatientStart = self._fileCounter 86 fileCounterAtPatientStart = self._fileCounter
97 s=endTimePatient - startTimePatient, 101 s=endTimePatient - startTimePatient,
98 x=(self._fileCounter - fileCounterAtPatientStart)/(endTimePatient - startTimePatient) 102 x=(self._fileCounter - fileCounterAtPatientStart)/(endTimePatient - startTimePatient)
99 )) 103 ))
100 resultWriter.writerow([ 104 resultWriter.writerow([
101 patientIndex, 105 patientIndex,
102 self._fileCounter - fileCounterAtPatientStart, 106 self._fileCounter,
103 endTimePatient - startTimePatient,
104 (self._fileCounter - fileCounterAtPatientStart)/(endTimePatient - startTimePatient) 107 (self._fileCounter - fileCounterAtPatientStart)/(endTimePatient - startTimePatient)
105 ]) 108 ])
106 resultFile.flush() 109 resultFile.flush()
107 110
108 endTime = time.time() 111 endTime = time.time()