Author: gnichols Date: 2011-08-31 14:37:12 +0000 (Wed, 31 Aug 2011) New Revision: 1056
Modified: trunk/tests/cpuscaling/cpuscaling.py Log: 732113 - cpuscaling rewrite
Modified: trunk/tests/cpuscaling/cpuscaling.py =================================================================== --- trunk/tests/cpuscaling/cpuscaling.py 2011-08-31 14:36:52 UTC (rev 1055) +++ trunk/tests/cpuscaling/cpuscaling.py 2011-08-31 14:37:12 UTC (rev 1056) @@ -29,18 +29,34 @@ from v7.device import Device from v7.command import Command, V7CommandException
+""" + Tolerance Calculation, workload time checks: + + p = predicted speedup = (max freq / min freq) + s = measured speedup = (workload time, min freq / workload time, max freq) + t = tolerance + + p - (p - 1.0)*t < s < p + (p - 1.0) + + example: p = 2.0, s = 1.9, t = 0.5 + 2.0 - (2.0 - 1.0)*0.5 < 1.9 < 2.0 + (2.0-1.0)*.5 + evaluates to: + 1.5 < 1.9 < 2.5 = True (PASS) +"""
+ class CPUScalingTest(Test):
def __init__(self): Test.__init__(self, name="cpuscaling") - self.speedUpTolerance = 10.0 # percent + self.speedUpTolerance = 50.0 # percent + self.frequencyTolerance = 50 # MHz, +/- self.retryLimit = 5 self.retryTolerance = 5.0 # percent self.sysCPUDirectory = "/sys/devices/system/cpu" self.idaFlag = "ida" + self.aperfmperfFlag = "aperfmperf" self.idaSpeedupFactor = 8.0 # percent - self.turboSpeedupTolerance = 5.0 # percent - test expects turbo/ida to increase performance by more than this self.selfTestData = [10.0, 10.0, 10.0, 10.0] # min, max, ondemand, performance self.selfTestStep = 0 self.deviceClass = DeviceClass.processor @@ -48,7 +64,11 @@ self.cpuToPackage = None self.packageToCpus = None self.workloads = ["minimum", "maximum", "ondemand", "performance"] + self.workloadNames = {"minimum": "User Space (min)", "maximum": "User Space (max)", "ondemand": "On Demand", "performance": "Performance"} self.workloadTime = dict() # workload run time list indexed by [workload][cpu] + self.workloadFreq = dict() # measured cpu freq indexed by [workload][cpu] + self.workloadErrors = dict() # error log indexed by [workload] + self.currentWorkload = "minimum"
def setWorkloadTime(self, workload, cpu, time): if not workload in self.workloadTime: @@ -56,6 +76,20 @@ if not cpu in self.workloadTime[workload]: self.workloadTime[workload][cpu] = list() self.workloadTime[workload][cpu].append(time) + + def setWorkloadFreq(self, workload, cpu, freq): + if not workload in self.workloadFreq: + self.workloadFreq[workload] = dict() + if not cpu in self.workloadFreq[workload]: + self.workloadFreq[workload][cpu] = list() + mhz = int(freq)/1000 + self.workloadFreq[workload][cpu].append(mhz) + + def logWorkloadError(self, errorMessage): + print errorMessage + if not self.currentWorkload in self.workloadErrors: + self.workloadErrors[self.currentWorkload] = list() + self.workloadErrors[self.currentWorkload].append(errorMessage)
def getWorkloadTime(self, workload, cpu): try: @@ -63,6 +97,12 @@ except KeyError: return None
+ def getWorkloadFreq(self, workload, cpu): + try: + return self.workloadFreq[workload][cpu][-1] # get the last time + except KeyError: + return None + def getWorkloadTimes(self, workload, cpu): try: return self.workloadTime[workload][cpu] # get the whole list of times @@ -76,15 +116,34 @@ max = len(self.workloadTime[workload][cpu]) return max
- def speedup(self, cpu): - return self.getWorkloadTime("minimum", cpu)/self.getWorkloadTime("maximum", cpu) + def speedup(self, cpu, workload="maximum"): + try: + return self.getWorkloadTime("minimum", cpu)/self.getWorkloadTime(workload, cpu) + except Exception, e: + print "Error: could not determine speedup for workload %s" % workload + print e + return None
- def speedupMargin(self, cpu): - return (abs(self.speedup(cpu)-self.predictedSpeedup)/self.predictedSpeedup)*100 - - def margin(self, cpu, workload): - return (abs(self.getWorkloadTime(workload,cpu)-self.getWorkloadTime("maximum",cpu))/self.getWorkloadTime("maximum",cpu))*100 + def checkFrequency(self, freq1, freq2): + # freq1 and freq2 is strings, in KHz + return abs(int(freq1)-int(freq2)) < self.frequencyTolerance*1000 # MHz->KHz
+ def checkSpeedup(self, speedup): + success = True + if speedup < self.minimumRequiredSpeedup(): + self.logWorkloadError("Error: measured speedup %.2f less that the required minimum speedup of %.2f. " % (speedup, self.minimumRequiredSpeedup())) + success = False + if speedup > self.maximumRequiredSpeedup(): + self.logWorkloadError("Error: measured speedup %.2f greater than the maximum speedup of %.2f" % (speedup, self.maximumRequiredSpeedup())) + success = False + return success + + def minimumRequiredSpeedup(self): + return self.predictedSpeedup - ((self.predictedSpeedup - 1.00)*self.speedUpTolerance/100.0) + + def maximumRequiredSpeedup(self): + return self.predictedSpeedup + ((self.predictedSpeedup - 1.00)*self.speedUpTolerance/100.0) + def tags(self): return [TestTag.noninteractive, TestTag.certification]
@@ -165,15 +224,15 @@ return line.strip().split() return None
- def setPackageParameter(self, switch, setFile, readFile, value): + def setPackageParameter(self, switch, setFile, readFile, value, verify=True): # try the command for all cpus in the package result = True for cpu in self.packageToCpus[self.currentPackage]: - if not self.setParameter(cpu, switch, setFile, readFile, value): + if not self.setParameter(cpu, switch, setFile, readFile, value, verify): result = False return result
- def setParameter(self, cpu, switch, setFile, readFile, value): + def setParameter(self, cpu, switch, setFile, readFile, value, verify=True): result = True try: command = Command("cpufreq-selector -c %s -%s %s" % (cpu, switch, value)) @@ -194,32 +253,70 @@ return False
# verify it has changed - parameterFile = open("%s/%s" % (self.cpufreqDirectories[cpu], readFile)) - line = parameterFile.readline() - if not line or line.strip() != value: - print "Error: could not verify that %s/%s was set to %s" % (self.cpufreqDirectories[cpu], readFile, value) - if line: - print "Actual Value: %s" % line - else: - print "parameter file was empty" - return False + if verify: + parameterFile = open("%s/%s" % (self.cpufreqDirectories[cpu], readFile)) + line = parameterFile.readline() + if not line or line.strip() != value: + self.logWorkloadError("Error: could not verify that %s/%s was set to %s" % (self.cpufreqDirectories[cpu], readFile, value)) + if line: + print "Actual Value: %s" % line + else: + print "parameter file was empty" + return False
return True
def setFrequency(self, frequency): - return self.setPackageParameter("f", "scaling_setspeed", "scaling_cur_freq", frequency) + if self.setPackageParameter("f", "scaling_setspeed", "scaling_cur_freq", frequency, verify=False): + return self.getFrequency() + + # otherwise, set command has failed + return None
+ def getFrequency(self, cpu=None): + if not cpu: + cpuInfoCurrentFreq = self.getPackageParameter("cpuinfo_cur_freq", logging=True) + # scalingCurrentFreq = self.getPackageParameter("scaling_cur_freq", logging=True) + # if cpuInfoCurrentFreq != scalingCurrentFreq: + # print "Warning: scaling_cur_freq is %s while cpuinfo_cur_freq is %s" % ( scalingCurrentFreq, cpuInfoCurrentFreq) + if cpuInfoCurrentFreq: + # print "Using cpuinfo_cur_freq" + return cpuInfoCurrentFreq + + # otherwise + # if scalingCurrentFreq: + # print "Using scaling_cur_freq" + # return scalingCurrentFreq + + self.logWorkloadError("Error: could not determine frequency") + return None + else: + cpuInfoCurrentFreq = self.getParameter(cpu, "cpuinfo_cur_freq") + # scalingCurrentFreq = self.getParameter(cpu, "scaling_cur_freq") + if cpuInfoCurrentFreq: + return cpuInfoCurrentFreq + + # otherwise + # if scalingCurrentFreq: + # return scalingCurrentFreq + + self.logWorkloadError("Error: could not determine frequency") + return None + + def setGovernor(self, governor): return self.setPackageParameter("g", "scaling_governor", "scaling_governor", governor)
- def getPackageParameter(self, parameter): + def getPackageParameter(self, parameter, logging=False): packageParameterValue = None for cpu in self.packageToCpus[self.currentPackage]: value = self.getParameter(cpu, parameter) + if logging: + print "cpu%s %s = %s" % (cpu, parameter, value) if value and not packageParameterValue: packageParameterValue = value elif value != packageParameterValue: - print "Error: cpu%s in package %s has the value %s which differs from other cpus in the package" % (cpu, self.currentPackage, value) + self.logWorkloadError("Error: cpu%s in package %s has the value %s which differs from other cpus in the package" % (cpu, self.currentPackage, value)) return None return packageParameterValue
@@ -230,12 +327,12 @@ parameterFile = open(parameterFilePath) line = parameterFile.readline() if not line: - print "Error: failed to get %s for %s" % (parameter, self.cpufreqDirectories[cpu]) + self.logWorkloadError("Error: failed to get %s for %s" % (parameter, self.cpufreqDirectories[cpu])) return None value = line.strip() return value except IOError, exception: - print "Error: could not open %s" % parameterFilePath + self.logWorkloadError("Error: could not open %s" % parameterFilePath) print exception
return None @@ -246,7 +343,7 @@ parameterFile = open("%s/%s" % (cpufreqDirectory, parameter)) line = parameterFile.readline() if not line: - print "Error: failed to get %s for %s" % (parameter, cpufreqDirectory) + self.logWorkloadError("Error: failed to get %s for %s" % (parameter, cpufreqDirectory)) return None values.append(line.strip())
@@ -261,20 +358,21 @@ while tries < self.retryLimit: sys.stdout.flush() averageProcessTime = self.__runSubprocessLoadTest(cpu) - print "average worker process time: %.2f seconds" % averageProcessTime - if not runTime: - runTime = averageProcessTime - else: - thisTime = averageProcessTime - # print "comparing %.2f" % (abs(thisTime-runTime)/runTime) - if (abs(thisTime-runTime)/runTime)*100 < self.retryTolerance: - return thisTime + if averageProcessTime: + print "average worker process time: %.2f seconds" % averageProcessTime + if not runTime: + runTime = averageProcessTime else: - runTime = thisTime + thisTime = averageProcessTime + # print "comparing %.2f" % (abs(thisTime-runTime)/runTime) + if (abs(thisTime-runTime)/runTime)*100 < self.retryTolerance: + return thisTime + else: + runTime = thisTime tries += 1 # print "try %u - %.2f sec" % (tries, runTime)
- print "Error: could not repeat load test times within %.1f%%" % self.retryTolerance + self.logWorkloadError("Error: could not repeat load test times within %.1f%%" % self.retryTolerance) return None
def __runSubprocessLoadTest(self, cpu=None): @@ -299,15 +397,20 @@ for (cpu, process) in self.loadProcesses.items(): if process.isDone(): if process.returnCode is not 0: - print "Error: load process terminated with return code " + process.returnCode + self.logWorkloadError("Error: load process terminated with return code " + process.returnCode) return None runTime = process.getRunTime() + frequency = self.getFrequency(cpu) if not runTime: - print "Error: could not find process run time" + self.logWorkloadError("Error: could not find process run time") return None + if not frequency: + self.logWorkloadError("Error: could not determine cpu frequency") + return None # otherwise - collect info - print "process for cpu %s is done in %.2f seconds" % (cpu, runTime) + print "process for cpu %s is done in %.2f seconds, at %u MHz" % (cpu, runTime, int(int(frequency)/1000)) self.setWorkloadTime(self.currentWorkload, cpu, runTime) + self.setWorkloadFreq(self.currentWorkload, cpu, frequency) totalProcessTime += runTime del self.loadProcesses[cpu]
@@ -320,7 +423,7 @@ try: del self.loadProcesses[cpu] except KeyError: - print "Error: no cpu %s in load processes" % cpu + self.logWorkloadError("Error: no cpu %s in load processes" % cpu)
def verifyMinimumFrequency(self): waitTime = 5 @@ -329,8 +432,8 @@ time.sleep(waitTime) sys.stdout.write(" done.\n") minimumFrequency = self.getPackageParameter("scaling_min_freq") - currentFrequency = self.getPackageParameter("scaling_cur_freq") - if not minimumFrequency or not currentFrequency or (minimumFrequency != currentFrequency): + currentFrequency = self.getFrequency() + if not minimumFrequency or not currentFrequency or not self.checkFrequency(minimumFrequency, currentFrequency): return False
# otherwise @@ -413,12 +516,21 @@ sys.stdout.write(" cpu%u: %s\n" % (i, g)) i += 1 else: - print "Error: could not determine current governor settings" + self.logWorkloadError("Error: could not determine current governor settings") return False
+ print "\nCPU Flags:" self.getCPUFlags() + support = " NOT" + if self.idaFlag in self.cpuFlags: + support = "" + print " %s: Turbo Boost is%s supported" % (self.idaFlag, support) + support = " NOT" + if self.aperfmperfFlag in self.cpuFlags: + support = "" + print " %s: aperf/mperf is%s supported"% (self.aperfmperfFlag, support) sys.stdout.flush()
return True @@ -452,10 +564,6 @@ # 5. Set the govr.(*) to "userspace" for each cpu via a command similar to: # 6. Verify the govr. setting took by checking ~/scaling_governor self.differenceSpeedUp = None - # calculate predicted (theoretical) speed up based on scaling frequencies - maximumFrequency = self.getPackageParameter("scaling_max_freq") - minimumFrequency = self.getPackageParameter("scaling_min_freq") - self.predictedSpeedup = string.atof(maximumFrequency)/string.atof(minimumFrequency)
success = True governor = "userspace" @@ -466,7 +574,7 @@
# 7. Set the the cpu speed to it's lowest value frequency = self.frequencies[0] - currentFrequency = self.getPackageParameter("scaling_cur_freq") + currentFrequency = self.getFrequency() if currentFrequency: print "Changing cpu frequency from %u to %u MHz" % (int(currentFrequency)/1000, (frequency/1000)) else: @@ -477,9 +585,10 @@ sys.stdout.flush()
# 8. Verify the speed is set to the lowest value by comparing ~/scaling_min_freq to ~/scaling_cur_freq - currentFrequency = self.getPackageParameter("scaling_cur_freq") - if not minimumFrequency or not currentFrequency or (minimumFrequency != currentFrequency): - print "Error: Could not verify that cpu frequency is set to the minimum value of %s" % minimumFrequency + currentFrequency = self.getFrequency() + minimumFrequency = self.getPackageParameter("scaling_min_freq") + if not minimumFrequency or not currentFrequency or not self.checkFrequency(minimumFrequency, currentFrequency): + self.logWorkloadError("Error: Could not verify that cpu frequency is set to the minimum value of %s" % minimumFrequency) success = False
# 9. Run and time non-cacheable work(?) test for each CPU @@ -492,15 +601,23 @@
# 11. Set the cpu speed to it's highest value as above. frequency = self.frequencies[-1] - currentFrequency = self.getPackageParameter("scaling_cur_freq") + currentFrequency = self.getFrequency() print "Changing cpu frequency from %u to %u MHz" % (int(currentFrequency)/1000, (frequency/1000)) if not self.setFrequency("%u" % frequency): success = False self.currentWorkload = "maximum"
- currentFrequency = self.getPackageParameter("scaling_cur_freq") - if not maximumFrequency or not currentFrequency or (maximumFrequency != currentFrequency): - print "Error: Could not verify that cpu frequency is set to the maximum value of %s" % maximumFrequency + currentFrequency = self.getFrequency() + maximumFrequency = self.getPackageParameter("scaling_max_freq") + try: + self.predictedSpeedup = float(maximumFrequency)/float(minimumFrequency) + except Exception, e: + print "Error: could not determine predicted speedup" + print e + return False + + if not maximumFrequency or not currentFrequency or not self.checkFrequency(maximumFrequency, currentFrequency): + self.logWorkloadError("Error: Could not verify that cpu frequency is set to the maximum value of %s" % maximumFrequency) success = False
# 12. Repeat workload test, record timing @@ -519,10 +636,7 @@ print "" print "CPU Frequency Speed Up: %.2f" % self.predictedSpeedup print "CPU %s Measured Speed Up: %.2f" % (cpu, measuredSpeedup) - self.differenceSpeedUp = self.speedupMargin(cpu) - print "Percentage Difference %.1f%%" % self.differenceSpeedUp - if self.differenceSpeedUp > self.speedUpTolerance: - print "Error: measured speedup vs expected speedup is %.1f%% and is not within %.1f%% margin. " % (self.differenceSpeedUp, self.speedUpTolerance) + if not self.checkSpeedup(measuredSpeedup): success = False else: print "Note: %s governor not supported" % governor @@ -547,7 +661,7 @@
# 16. Wait a fixed period of time, then verify current speed is the slowest in as before if not self.verifyMinimumFrequency(): - print "Error: Could not verify that cpu frequency has settled to the minimum value" + self.logWorkloadError("Error: Could not verify that cpu frequency has settled to the minimum value") success = False
# 17. Repeat workload test, record timing; also during testing verify the ~scaling_cur_freq reaches ~scaling_max_freq @@ -560,10 +674,9 @@ # for each cpu in the package for cpu in self.packageToCpus[self.currentPackage]: if self.getWorkloadTime("maximum", cpu): - self.differenceOnDemandVsMaximum = self.margin(cpu, "ondemand") - print "CPU %s Percentage Difference vs. maximum frequency: %.1f%%" % (cpu, self.differenceOnDemandVsMaximum) - if self.differenceOnDemandVsMaximum > self.speedUpTolerance: - print "Error: on demand performance vs maximum of %.1f%% is not within %.1f%% margin" % (self.differenceOnDemandVsMaximum, self.speedUpTolerance) + onDemandSpeedup = self.speedup(cpu, "ondemand") + print "CPU %s Speedup On Demand: %.2f%%" % (cpu, onDemandSpeedup) + if not self.checkSpeedup(onDemandSpeedup): success = False else: print "No maximum frequency test data to compare" @@ -571,7 +684,7 @@
# 19. Verify the current speed has returned to the lowest speed as before if not self.verifyMinimumFrequency(): - print "Error: Could not verify that cpu frequency has settled to the minimum value" + self.logWorkloadError("Error: Could not verify that cpu frequency has settled to the minimum value") success = False else: print "Note: %s governor not supported" % governor @@ -595,10 +708,13 @@
# 21. Verify the current speed is the same as scaling_max_freq maximumFrequency = self.getPackageParameter("scaling_max_freq") - currentFrequency = self.getPackageParameter("scaling_cur_freq") - if not maximumFrequency or not currentFrequency or (maximumFrequency != currentFrequency): - print "Error: Current cpu frequency of %.2f is not set to the maximum value of %.2f" % (currentFrequency, maximumFrequency) + currentFrequency = self.getFrequency() + if not maximumFrequency or not currentFrequency: + self.logWorkloadError("Error: could not determine current frequency") return False + elif not self.checkFrequency(maximumFrequency, currentFrequency): + self.logWorkloadError("Error: Current cpu frequency of %.2f is not set to the maximum value of %.2f" % (currentFrequency, maximumFrequency)) + return False
# 22. Repeat workload test, record timing, also verify frequency does not drop during run self.performanceTestTime = self.runLoadTest() @@ -609,11 +725,10 @@
# 23. Compare the timing to the max results for a self.speedUpTolerance delta for cpu in self.packageToCpus[self.currentPackage]: - self.differencePerformanceVsMaximum = self.margin(cpu, "performance") - print "CPU %s Percentage Difference vs. maximum frequency: %.1f%%" % (cpu, self.differencePerformanceVsMaximum) - if self.differencePerformanceVsMaximum > self.speedUpTolerance: - print "Error: performance setting vs maximum of %.1f%% is not within %.1f%% margin" % (self.differencePerformanceVsMaximum, self.speedUpTolerance) - success = False + performanceSpeedup = self.speedup(cpu, "performance") + print "CPU %s Performance Speedup: %.2f%%" % (cpu, performanceSpeedup) + if not self.checkSpeedup(performanceSpeedup): + success = False
else: print "Note: %s governor not supported" % governor @@ -649,14 +764,16 @@ print "Turbo/IDA load test time: %.2f" % self.turboTestTime
# 23. Compare the timing to the max results for a self.speedUpTolerance delta - self.differenceTurboVsMaximum = self.margin(turboCpu, "turbo") - print "Percentage Difference vs. maximum frequency: %.1f%%" % self.differenceTurboVsMaximum - if self.differenceTurboVsMaximum < self.turboSpeedupTolerance: - print "Error: turbo/IDA setting vs maximum of %.1f%% is not within %.1f%% margin" % (self.differenceTurboVsMaximum, self.turboSpeedupTolerance) - success = False + turboSpeedup = self.speedup(turboCpu, "turbo") + if not turboSpeedup: + return False + print "Turbo Speedup: %.1f%%" % turboSpeedup
+ if not self.checkSpeedup(turboSpeedup): + success = False + else: - print "Error: %s governor not supported" % governor + self.logWorkloadError("Error: %s governor not supported" % governor) success = False
return success @@ -676,64 +793,69 @@ for package in self.packageToCpus.keys(): self.printSummary(package)
- for package in self.packageToCpus.keys(): - self.printWorkloadTimeSummary(package) + if False: # disable for now: + for package in self.packageToCpus.keys(): + self.printWorkloadTimeSummary(package)
+ if self.workloadErrors: + print "\nError Summary:" + print "----------------" + for workload in self.workloads: + if workload in self.workloadErrors: + for error in self.workloadErrors[workload]: + print "%s: %s" % (self.workloadNames[workload], error) + return False + return True
def printSummary(self, package): - """ tables: row title is 13 characters, each cpu cell is 9 characters """ + print "" print "Summary for Package %s:" % package - self.__printBorder(package) - sys.stdout.write("Workload ") + print "\nCPU Frequency Test:\n" + print " User Min User Max Performance" + print "-------- -------------- -------------- --------------" + + # expected values + minimumFrequency = int(self.getPackageParameter("scaling_min_freq"))/1000 + maximumFrequency = int(self.getPackageParameter("scaling_max_freq"))/1000 + print "expected %5u MHz %5u MHz %5u MHz" % (minimumFrequency, maximumFrequency, maximumFrequency) + + #actual values, one row per cpu for cpu in self.packageToCpus[package]: - sys.stdout.write(" cpu %-3s " % cpu) + sys.stdout.write("cpu %-3s " % cpu) + for workload in self.workloads: + if workload in self.workloadTime and workload != "ondemand" and workload != "turbo": + sys.stdout.write(" %4u" % self.getWorkloadFreq(workload, cpu)) + sys.stdout.write((" (%.2fs) " % self.getWorkloadTime(workload, cpu))[:10]) + print "" + print "" - self.__printBorder(package) - for workload in self.workloads: - if workload in self.workloadTime: - sys.stdout.write("%-13s" % workload) - for cpu in self.packageToCpus[package]: - sys.stdout.write("%9.2f" % self.getWorkloadTime(workload, cpu)) - print "" - print "\n"
- sys.stdout.write("Speedup ") - for cpu in self.packageToCpus[package]: - sys.stdout.write(" cpu %-3s " % cpu) + + print "\nCPU Workload Test:\n" + print "Expected Speedup: %.2f" % self.predictedSpeedup + print "Allowable Speedup: %.2f to %.2f" % (self.minimumRequiredSpeedup(), self.maximumRequiredSpeedup()) print "" - self.__printBorder(package) - sys.stdout.write("expected ") + print " On Demand Single CPU " + print "-------- -------------- --------------" + + #actual values, one row per cpu for cpu in self.packageToCpus[package]: - sys.stdout.write("%9.2f" % self.predictedSpeedup) - print "" - sys.stdout.write("actual ") - for cpu in self.packageToCpus[package]: - sys.stdout.write("%9.2f" % self.speedup(cpu)) - print "" - sys.stdout.write("margin ") - for cpu in self.packageToCpus[package]: - sys.stdout.write("%8.2f%%" % self.speedupMargin(cpu)) - print "" - for workload in ["ondemand", "performance"]: - if workload in self.workloadTime.keys(): # iterate over logged workloads - sys.stdout.write("%-13s" % workload) - for cpu in self.packageToCpus[package]: - sys.stdout.write("%8.2f%%" % self.margin(cpu, workload)) - print "" - if "turbo" in self.workloadTime: - sys.stdout.write("%-13s" % "turbo") - turboCpu = self.getTurboCpu() - for cpu in self.packageToCpus[package]: - if cpu == turboCpu: - sys.stdout.write("%8.2f%%" % self.margin(cpu, "turbo")) - else: - sys.stdout.write(" - ") + sys.stdout.write("cpu %-3s " % cpu) + for workload in ["ondemand", "turbo"]: + if workload in self.workloadTime: + workloadTime = self.getWorkloadTime(workload, cpu) + if workloadTime: + sys.stdout.write(" %.2f" % self.speedup(cpu, workload)) + sys.stdout.write((" (%.2fs) " % workloadTime)[:10]) + else: + sys.stdout.write(" - ") print "" - print "\n"
+ print "" + def printWorkloadTimeSummary(self, package): sys.stdout.write("Workload run times for package %s:\n" % package) sys.stdout.write("-------------------\n") @@ -759,10 +881,13 @@ print "" print "\n"
- def __printBorder(self, package): + def __printBorder(self, package, cell): sys.stdout.write("-------------") # 13 for row title + cellBorder = " " + for i in range(cell): + cellBorder = cellBorder + "-" for cpu in self.packageToCpus[package]: - sys.stdout.write(" --------") # 9 for cpu cell ( 1 space, 8 -) + sys.stdout.write(cellBorder) # 15 for cpu cell ( 1 space, 14 -) sys.stdout.write("\n")
def run(self): @@ -784,17 +909,16 @@ if not self.runSubTest(self.runUserSpaceTests, "User Space, package %s" % package): result = FAILED
- if not self.runSubTest(self.runOnDemandTests, "On Demand, package %s" % package): result = FAILED - + if not self.runSubTest(self.runPerformanceTests, "Performance, package %s" % package): result = FAILED
if self.turboBoostSupported(): if not self.runSubTest(self.runTurboBoostTest, "Turbo Boost/IDA, package %s" % package): result = FAILED - +
self.restoreGovernors()
@@ -840,20 +964,21 @@ self.owner.done(self.cpu)
def isDone(self): - if self.workProcess and self.workProcess.poll() is not None: + if self.workProcess: self.returnCode = self.workProcess.poll() - while True: - line = self.workProcess.readline() - if line: - try: - self.runTime = float(line) - return True - except ValueError: - pass # keep trying - else: - print "Error: could not determine process run time" - break - return True + if self.returnCode is not None: + while True: + line = self.workProcess.readline() + if line: + try: + self.runTime = float(line) + return True + except ValueError, e: + pass # keep trying + else: + print "Error: could not determine process run time" + break + return True # otherwise return False
@@ -881,7 +1006,9 @@ pi() (stop_utime, stop_stime, stop_cutime, stop_cstime, stop_elapsed_time) = os.times() runTime = stop_elapsed_time - start_elapsed_time + print "" # make sure runTime is on its own line print runTime + sys.stdout.flush() sys.exit(0)
test = CPUScalingTest()
v7-commits@lists.stg.fedorahosted.org