Merge lp:~cr3/checkbox/cpu_scaling_test into lp:checkbox
- cpu_scaling_test
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 1455 |
Proposed branch: | lp:~cr3/checkbox/cpu_scaling_test |
Merge into: | lp:checkbox |
Diff against target: |
544 lines (+103/-104) (has conflicts) 2 files modified
debian/changelog (+5/-0) scripts/cpu_scaling_test (+98/-104) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~cr3/checkbox/cpu_scaling_test |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brendan Donegan (community) | Approve | ||
Review via email: mp+110394@code.launchpad.net |
Commit message
Description of the change
ubuntu@
System Capabilites:
-------
System has 4 cpus
Supported CPU Frequencies:
2400 MHz
2399 MHz
2266 MHz
2133 MHz
1999 MHz
1866 MHz
1733 MHz
1599 MHz
1466 MHz
1333 MHz
1199 MHz
Supported Governors:
conservative
ondemand
userspace
powersave
performance
Current governors:
cpu0: userspace
cpu1: userspace
cpu2: userspace
cpu3: userspace
Userspace Governor Test:
-------
Setting governor to userspace
Setting CPU frequency to 1199 MHz
Running CPU load test...
pid 7018's current affinity list: 0-3
pid 7018's new affinity list: 0
Minimum frequency load test time: 6.47
Setting CPU frequency to 2400 MHz
Running CPU load test...
pid 7018's current affinity list: 0
pid 7018's new affinity list: 0
Maximum frequency load test time: 2.72
Note: found ida flag, increasing expected speedup by 8.0%
CPU Frequency Speed Up: 2.18
Measured Speed Up: 2.38
Percentage Difference 9.3%
On Demand Governor Test:
-------
Setting governor to ondemand
Waiting 5 seconds... done.
Running CPU load test...
pid 7018's current affinity list: 0
pid 7018's new affinity list: 0
On Demand load test time: 2.73
Percentage Difference vs. maximum frequency: 0.4%
Waiting 5 seconds... done.
Performance Governor Test:
-------
Setting governor to performance
Running CPU load test...
pid 7018's current affinity list: 0
pid 7018's new affinity list: 0
Performance load test time: 2.66
Percentage Difference vs. maximum frequency: 2.2%
Conservative Governor Test:
-------
Setting governor to conservative
Waiting 10 seconds... done.
Running CPU load test...
pid 7018's current affinity list: 0
pid 7018's new affinity list: 0
Conservative load test time: 6.57
Percentage Difference vs. minimum frequency: 1.5%
Restoring original governor to userspace
ubuntu@
0
... that is all
- 1412. By Marc Tardif
-
Migrated from OptionParser to argparse.
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2012-06-13 20:09:23 +0000 |
3 | +++ debian/changelog 2012-06-14 19:48:19 +0000 |
4 | @@ -18,10 +18,15 @@ |
5 | a test for the Super key. |
6 | * [FEATURE] Added new interactive and auto-verifying touchpad scrolling |
7 | test. |
8 | +<<<<<<< TREE |
9 | * [FEATURE] Python 2 to 3 conversion: |
10 | * scripts/cking_suite |
11 | * scripts/ansi_parser |
12 | * scripts/network_bandwidth_test |
13 | +======= |
14 | + * [FEATURE] Python 2 to 3 conversion: |
15 | + * scripts/cpu_scaling_test |
16 | +>>>>>>> MERGE-SOURCE |
17 | * Removed sleep_test script no longer used by any test definition. |
18 | |
19 | [Daniel Manrique] |
20 | |
21 | === modified file 'scripts/cpu_scaling_test' |
22 | --- scripts/cpu_scaling_test 2012-05-22 18:01:21 +0000 |
23 | +++ scripts/cpu_scaling_test 2012-06-14 19:48:19 +0000 |
24 | @@ -1,13 +1,12 @@ |
25 | -#!/usr/bin/python |
26 | +#!/usr/bin/env python3 |
27 | |
28 | import decimal |
29 | import os |
30 | import re |
31 | -import string |
32 | import sys |
33 | import time |
34 | +import argparse |
35 | |
36 | -from optparse import OptionParser |
37 | from subprocess import check_call, CalledProcessError |
38 | |
39 | |
40 | @@ -27,7 +26,7 @@ |
41 | |
42 | def getCPUFreqDirectories(self): |
43 | if not os.path.exists(self.sysCPUDirectory): |
44 | - print "Error: no file %s" % self.sysCPUDirectory |
45 | + print("Error: no file %s" % self.sysCPUDirectory) |
46 | return None |
47 | # look for cpu subdirectories |
48 | pattern = re.compile("cpu(?P<cpuNumber>[0-9]+)") |
49 | @@ -38,8 +37,8 @@ |
50 | cpufreqDirectory = os.path.join(self.sysCPUDirectory, |
51 | subdirectory, "cpufreq") |
52 | if not os.path.exists(cpufreqDirectory): |
53 | - print "Error: cpu %s has no cpufreq directory %s" \ |
54 | - % (match.group("cpuNumber"), cpufreqDirectory) |
55 | + print("Error: cpu %s has no cpufreq directory %s" \ |
56 | + % (match.group("cpuNumber"), cpufreqDirectory)) |
57 | return None |
58 | # otherwise |
59 | self.cpufreqDirectories.append(cpufreqDirectory) |
60 | @@ -53,8 +52,8 @@ |
61 | for cpufreqDirectory in self.cpufreqDirectories: |
62 | parameters = self.getParameters(cpufreqDirectory, file) |
63 | if not parameters: |
64 | - print "Error: could not determine cpu parameters from %s" \ |
65 | - % os.path.join(cpufreqDirectory, file) |
66 | + print("Error: could not determine cpu parameters from %s" \ |
67 | + % os.path.join(cpufreqDirectory, file)) |
68 | return None |
69 | if not current: |
70 | current = parameters |
71 | @@ -92,9 +91,9 @@ |
72 | |
73 | try: |
74 | check_call("echo \"%s\" > %s" % (value, path), shell=True) |
75 | - except CalledProcessError, exception: |
76 | - print "Error: command failed:" |
77 | - print exception |
78 | + except CalledProcessError as exception: |
79 | + print("Error: command failed:") |
80 | + print(exception) |
81 | return False |
82 | |
83 | # verify it has changed |
84 | @@ -106,12 +105,12 @@ |
85 | parameterFile = open(path) |
86 | line = parameterFile.readline() |
87 | if not line or line.strip() != str(value): |
88 | - print ("Error: could not verify that %s was set to %s" |
89 | + print("Error: could not verify that %s was set to %s" |
90 | % (path, value)) |
91 | if line: |
92 | - print "Actual Value: %s" % line |
93 | + print("Actual Value: %s" % line) |
94 | else: |
95 | - print "parameter file was empty" |
96 | + print("parameter file was empty") |
97 | return False |
98 | |
99 | return True |
100 | @@ -142,8 +141,8 @@ |
101 | try: |
102 | check_call("cpufreq-selector -%s %s" |
103 | % (switch, value), shell=True) |
104 | - except CalledProcessError, exception: |
105 | - print "Note: command failed: %s" % exception.cmd |
106 | + except CalledProcessError as exception: |
107 | + print("Note: command failed: %s" % exception.cmd) |
108 | skip = False |
109 | else: |
110 | skip = False |
111 | @@ -165,14 +164,14 @@ |
112 | parameterFile = open(parameterFilePath) |
113 | line = parameterFile.readline() |
114 | if not line: |
115 | - print ("Error: failed to get %s for %s" |
116 | + print("Error: failed to get %s for %s" |
117 | % (parameter, self.cpufreqDirectory)) |
118 | return None |
119 | value = line.strip() |
120 | return value |
121 | - except IOError, exception: |
122 | - print "Error: could not open %s" % parameterFilePath |
123 | - print exception |
124 | + except IOError as exception: |
125 | + print("Error: could not open %s" % parameterFilePath) |
126 | + print(exception) |
127 | |
128 | return None |
129 | |
130 | @@ -183,19 +182,19 @@ |
131 | parameterFile = open(path) |
132 | line = parameterFile.readline() |
133 | if not line: |
134 | - print ("Error: failed to get %s for %s" |
135 | + print("Error: failed to get %s for %s" |
136 | % (parameter, cpufreqDirectory)) |
137 | return None |
138 | values.append(line.strip()) |
139 | return values |
140 | |
141 | def runLoadTest(self): |
142 | - print "Running CPU load test..." |
143 | + print("Running CPU load test...") |
144 | try: |
145 | check_call("taskset -pc 0 %s" % os.getpid(), shell=True) |
146 | - except CalledProcessError, exception: |
147 | - print "Error: could not set task affinity" |
148 | - print exception |
149 | + except CalledProcessError as exception: |
150 | + print("Error: could not set task affinity") |
151 | + print(exception) |
152 | return None |
153 | |
154 | runTime = None |
155 | @@ -218,7 +217,7 @@ |
156 | runTime = thisTime |
157 | tries += 1 |
158 | |
159 | - print ("Error: could not repeat load test times within %.1f%%" |
160 | + print("Error: could not repeat load test times within %.1f%%" |
161 | % self.retryTolerance) |
162 | return None |
163 | |
164 | @@ -251,15 +250,15 @@ |
165 | return True |
166 | |
167 | def getSystemCapabilities(self): |
168 | - print "" |
169 | - print "System Capabilites:" |
170 | - print "-------------------------------------------------" |
171 | + print("") |
172 | + print("System Capabilites:") |
173 | + print("-------------------------------------------------") |
174 | |
175 | # Do the CPUs support scaling? |
176 | if not self.getCPUFreqDirectories(): |
177 | return False |
178 | if len(self.cpufreqDirectories) > 1: |
179 | - print "System has %u cpus" % len(self.cpufreqDirectories) |
180 | + print("System has %u cpus" % len(self.cpufreqDirectories)) |
181 | |
182 | # Ensure all CPUs support the same frequencies |
183 | freqFileName = "scaling_available_frequencies" |
184 | @@ -267,11 +266,11 @@ |
185 | if not self.frequencies: |
186 | return False |
187 | |
188 | - print "" |
189 | - print "Supported CPU Frequencies: " |
190 | + print("") |
191 | + print("Supported CPU Frequencies: ") |
192 | for freq in self.frequencies: |
193 | - f = string.atoi(freq) / 1000 |
194 | - print " %u MHz" % f |
195 | + f = int(freq) / 1000 |
196 | + print(" %u MHz" % f) |
197 | |
198 | # Check governors to verify all CPUs support the same control methods |
199 | governorFileName = "scaling_available_governors" |
200 | @@ -279,21 +278,21 @@ |
201 | if not self.governors: |
202 | return False |
203 | |
204 | - print "" |
205 | - print "Supported Governors: " |
206 | + print("") |
207 | + print("Supported Governors: ") |
208 | for governor in self.governors: |
209 | - print " %s" % governor |
210 | + print(" %s" % governor) |
211 | |
212 | self.originalGovernors = self.getParameterList("scaling_governor") |
213 | if self.originalGovernors: |
214 | - print "" |
215 | - print "Current governors:" |
216 | + print("") |
217 | + print("Current governors:") |
218 | i = 0 |
219 | for g in self.originalGovernors: |
220 | - print " cpu%u: %s" % (i, g) |
221 | + print(" cpu%u: %s" % (i, g)) |
222 | i += 1 |
223 | else: |
224 | - print "Error: could not determine current governor settings" |
225 | + print("Error: could not determine current governor settings") |
226 | return False |
227 | |
228 | self.getCPUFlags() |
229 | @@ -313,12 +312,12 @@ |
230 | self.cpuFlags = post.strip().split() |
231 | break |
232 | except: |
233 | - print "Warning: could not read CPU flags" |
234 | + print("Warning: could not read CPU flags") |
235 | |
236 | def runUserSpaceTests(self): |
237 | - print "" |
238 | - print "Userspace Governor Test:" |
239 | - print "-------------------------------------------------" |
240 | + print("") |
241 | + print("Userspace Governor Test:") |
242 | + print("-------------------------------------------------") |
243 | self.minimumFrequencyTestTime = None |
244 | self.maximumFrequencyTestTime = None |
245 | |
246 | @@ -326,18 +325,17 @@ |
247 | differenceSpeedUp = None |
248 | governor = "userspace" |
249 | if governor not in self.governors: |
250 | - print "Note: %s governor not supported" % governor |
251 | + print("Note: %s governor not supported" % governor) |
252 | else: |
253 | |
254 | # Set the governor to "userspace" and verify |
255 | - print "Setting governor to %s" % governor |
256 | + print("Setting governor to %s" % governor) |
257 | if not self.setGovernor(governor): |
258 | success = False |
259 | |
260 | # Set the the CPU speed to it's lowest value |
261 | frequency = self.frequencies[-1] |
262 | - print ("Setting CPU frequency to %u MHz" |
263 | - % (string.atoi(frequency) / 1000)) |
264 | + print("Setting CPU frequency to %u MHz" % (int(frequency) / 1000)) |
265 | if not self.setFrequency(frequency): |
266 | success = False |
267 | |
268 | @@ -347,7 +345,7 @@ |
269 | if (not minimumFrequency |
270 | or not currentFrequency |
271 | or (minimumFrequency != currentFrequency)): |
272 | - print ("Error: Could not verify that cpu frequency " |
273 | + print("Error: Could not verify that cpu frequency " |
274 | "is set to the minimum value of %s" |
275 | % minimumFrequency) |
276 | success = False |
277 | @@ -359,13 +357,12 @@ |
278 | "test's execution time.") |
279 | success = False |
280 | else: |
281 | - print ("Minimum frequency load test time: %.2f" |
282 | + print("Minimum frequency load test time: %.2f" |
283 | % self.minimumFrequencyTestTime) |
284 | |
285 | # Set the CPU speed to it's highest value as above. |
286 | frequency = self.frequencies[0] |
287 | - print ("Setting CPU frequency to %u MHz" |
288 | - % (string.atoi(frequency) / 1000)) |
289 | + print("Setting CPU frequency to %u MHz" % (int(frequency) / 1000)) |
290 | if not self.setFrequency(frequency): |
291 | success = False |
292 | |
293 | @@ -374,7 +371,7 @@ |
294 | if (not maximumFrequency |
295 | or not currentFrequency |
296 | or (maximumFrequency != currentFrequency)): |
297 | - print ("Error: Could not verify that cpu frequency is set " |
298 | + print("Error: Could not verify that cpu frequency is set " |
299 | "to the maximum value of %s" |
300 | % maximumFrequency) |
301 | success = False |
302 | @@ -386,16 +383,16 @@ |
303 | "test's execution time.") |
304 | success = False |
305 | else: |
306 | - print ("Maximum frequency load test time: %.2f" |
307 | + print("Maximum frequency load test time: %.2f" |
308 | % self.maximumFrequencyTestTime) |
309 | |
310 | # Verify MHz increase is comparable to time % decrease |
311 | - predictedSpeedup = (string.atof(maximumFrequency) |
312 | - / string.atof(minimumFrequency)) |
313 | + predictedSpeedup = (float(maximumFrequency) |
314 | + / float(minimumFrequency)) |
315 | |
316 | # If "ida" turbo thing, increase the expectation by 8% |
317 | if self.cpuFlags and self.idaFlag in self.cpuFlags: |
318 | - print ("Note: found %s flag, increasing expected " |
319 | + print("Note: found %s flag, increasing expected " |
320 | "speedup by %.1f%%" |
321 | % (self.idaFlag, self.idaSpeedupFactor)) |
322 | predictedSpeedup = \ |
323 | @@ -405,14 +402,14 @@ |
324 | if self.minimumFrequencyTestTime and self.maximumFrequencyTestTime: |
325 | measuredSpeedup = (self.minimumFrequencyTestTime |
326 | / self.maximumFrequencyTestTime) |
327 | - print "" |
328 | - print "CPU Frequency Speed Up: %.2f" % predictedSpeedup |
329 | - print "Measured Speed Up: %.2f" % measuredSpeedup |
330 | + print("") |
331 | + print("CPU Frequency Speed Up: %.2f" % predictedSpeedup) |
332 | + print("Measured Speed Up: %.2f" % measuredSpeedup) |
333 | differenceSpeedUp = ((abs(measuredSpeedup - predictedSpeedup) |
334 | / predictedSpeedup) * 100) |
335 | - print "Percentage Difference %.1f%%" % differenceSpeedUp |
336 | + print("Percentage Difference %.1f%%" % differenceSpeedUp) |
337 | if differenceSpeedUp > self.speedUpTolerance: |
338 | - print ("Error: measured speedup vs expected speedup " |
339 | + print("Error: measured speedup vs expected speedup " |
340 | "is %.1f%% and is not within %.1f%% margin. " |
341 | % (differenceSpeedUp, self.speedUpTolerance)) |
342 | success = False |
343 | @@ -423,18 +420,18 @@ |
344 | return success |
345 | |
346 | def runOnDemandTests(self): |
347 | - print "" |
348 | - print "On Demand Governor Test:" |
349 | - print "-------------------------------------------------" |
350 | + print("") |
351 | + print("On Demand Governor Test:") |
352 | + print("-------------------------------------------------") |
353 | differenceOnDemandVsMaximum = None |
354 | onDemandTestTime = None |
355 | governor = "ondemand" |
356 | success = True |
357 | if governor not in self.governors: |
358 | - print "Note: %s governor not supported" % governor |
359 | + print("Note: %s governor not supported" % governor) |
360 | else: |
361 | # Set the governor to "ondemand" |
362 | - print "Setting governor to %s" % governor |
363 | + print("Setting governor to %s" % governor) |
364 | if not self.setGovernor(governor): |
365 | success = False |
366 | |
367 | @@ -448,10 +445,10 @@ |
368 | # Repeat workload test |
369 | onDemandTestTime = self.runLoadTest() |
370 | if not onDemandTestTime: |
371 | - print "Error: No On Demand load test time available." |
372 | + print("Error: No On Demand load test time available.") |
373 | success = False |
374 | else: |
375 | - print "On Demand load test time: %.2f" % onDemandTestTime |
376 | + print("On Demand load test time: %.2f" % onDemandTestTime) |
377 | |
378 | if onDemandTestTime and self.maximumFrequencyTestTime: |
379 | # Compare the timing to the max results from earlier, |
380 | @@ -459,10 +456,10 @@ |
381 | differenceOnDemandVsMaximum = \ |
382 | (abs(onDemandTestTime - self.maximumFrequencyTestTime) |
383 | / self.maximumFrequencyTestTime) * 100 |
384 | - print ("Percentage Difference vs. maximum frequency: %.1f%%" |
385 | + print("Percentage Difference vs. maximum frequency: %.1f%%" |
386 | % differenceOnDemandVsMaximum) |
387 | if differenceOnDemandVsMaximum > self.speedUpTolerance: |
388 | - print ("Error: on demand performance vs maximum of %.1f%% " |
389 | + print("Error: on demand performance vs maximum of %.1f%% " |
390 | "is not within %.1f%% margin" |
391 | % (differenceOnDemandVsMaximum, |
392 | self.speedUpTolerance)) |
393 | @@ -480,17 +477,17 @@ |
394 | return success |
395 | |
396 | def runPerformanceTests(self): |
397 | - print "" |
398 | - print "Performance Governor Test:" |
399 | - print "-------------------------------------------------" |
400 | + print("") |
401 | + print("Performance Governor Test:") |
402 | + print("-------------------------------------------------") |
403 | differencePerformanceVsMaximum = None |
404 | governor = "performance" |
405 | success = True |
406 | if governor not in self.governors: |
407 | - print "Note: %s governor not supported" % governor |
408 | + print("Note: %s governor not supported" % governor) |
409 | else: |
410 | # Set the governor to "performance" |
411 | - print "Setting governor to %s" % governor |
412 | + print("Setting governor to %s" % governor) |
413 | if not self.setGovernor(governor): |
414 | success = False |
415 | |
416 | @@ -500,7 +497,7 @@ |
417 | if (not maximumFrequency |
418 | or not currentFrequency |
419 | or (maximumFrequency != currentFrequency)): |
420 | - print ("Error: Current cpu frequency of %s " |
421 | + print("Error: Current cpu frequency of %s " |
422 | "is not set to the maximum value of %s" |
423 | % (currentFrequency, maximumFrequency)) |
424 | success = False |
425 | @@ -508,20 +505,20 @@ |
426 | # Repeat work load test |
427 | performanceTestTime = self.runLoadTest() |
428 | if not performanceTestTime: |
429 | - print "Error: No Performance load test time available." |
430 | + print("Error: No Performance load test time available.") |
431 | success = False |
432 | else: |
433 | - print "Performance load test time: %.2f" % performanceTestTime |
434 | + print("Performance load test time: %.2f" % performanceTestTime) |
435 | |
436 | if performanceTestTime and self.maximumFrequencyTestTime: |
437 | # Compare the timing to the max results |
438 | differencePerformanceVsMaximum = \ |
439 | (abs(performanceTestTime - self.maximumFrequencyTestTime) |
440 | / self.maximumFrequencyTestTime) * 100 |
441 | - print ("Percentage Difference vs. maximum frequency: %.1f%%" |
442 | + print("Percentage Difference vs. maximum frequency: %.1f%%" |
443 | % differencePerformanceVsMaximum) |
444 | if differencePerformanceVsMaximum > self.speedUpTolerance: |
445 | - print ("Error: performance setting vs maximum of %.1f%% " |
446 | + print("Error: performance setting vs maximum of %.1f%% " |
447 | "is not within %.1f%% margin" |
448 | % (differencePerformanceVsMaximum, |
449 | self.speedUpTolerance)) |
450 | @@ -533,17 +530,17 @@ |
451 | return success |
452 | |
453 | def runConservativeTests(self): |
454 | - print "" |
455 | - print "Conservative Governor Test:" |
456 | - print "-------------------------------------------------" |
457 | + print("") |
458 | + print("Conservative Governor Test:") |
459 | + print("-------------------------------------------------") |
460 | differenceConservativeVsMinimum = None |
461 | governor = "conservative" |
462 | success = True |
463 | if governor not in self.governors: |
464 | - print "Note: %s governor not supported" % governor |
465 | + print("Note: %s governor not supported" % governor) |
466 | else: |
467 | # Set the governor to "conservative" |
468 | - print "Setting governor to %s" % governor |
469 | + print("Setting governor to %s" % governor) |
470 | if not self.setGovernor(governor): |
471 | success = False |
472 | |
473 | @@ -568,10 +565,10 @@ |
474 | # Repeat work load test |
475 | conservativeTestTime = self.runLoadTest() |
476 | if not conservativeTestTime: |
477 | - print "Error: No Conservative load test time available." |
478 | + print("Error: No Conservative load test time available.") |
479 | success = False |
480 | else: |
481 | - print ("Conservative load test time: %.2f" |
482 | + print("Conservative load test time: %.2f" |
483 | % conservativeTestTime) |
484 | |
485 | if conservativeTestTime and self.minimumFrequencyTestTime: |
486 | @@ -579,10 +576,10 @@ |
487 | differenceConservativeVsMinimum = \ |
488 | (abs(conservativeTestTime - self.minimumFrequencyTestTime) |
489 | / self.minimumFrequencyTestTime) * 100 |
490 | - print ("Percentage Difference vs. minimum frequency: %.1f%%" |
491 | + print("Percentage Difference vs. minimum frequency: %.1f%%" |
492 | % differenceConservativeVsMinimum) |
493 | if differenceConservativeVsMinimum > self.speedUpTolerance: |
494 | - print ("Error: performance setting vs minimum of %.1f%% " |
495 | + print("Error: performance setting vs minimum of %.1f%% " |
496 | "is not within %.1f%% margin" |
497 | % (differenceConservativeVsMinimum, |
498 | self.speedUpTolerance)) |
499 | @@ -594,35 +591,32 @@ |
500 | return success |
501 | |
502 | def restoreGovernors(self): |
503 | - print "Restoring original governor to %s" % (self.originalGovernors[0]) |
504 | + print("Restoring original governor to %s" % (self.originalGovernors[0])) |
505 | self.setGovernor(self.originalGovernors[0]) |
506 | |
507 | |
508 | def main(args): |
509 | - usage = "Usage: %prog [OPTIONS]" |
510 | - parser = OptionParser(usage=usage) |
511 | - parser.add_option("-q", "--quiet", |
512 | - action="store_true", |
513 | - help="Suppress output.") |
514 | - parser.add_option("-c", "--capabilities", |
515 | - action="store_true", |
516 | - help="Only output CPU capabilities.") |
517 | - (options, args) = parser.parse_args(args) |
518 | + parser = argparse.ArgumentParser() |
519 | + parser.add_argument("-q", "--quiet", action="store_true", |
520 | + help="Suppress output.") |
521 | + parser.add_argument("-c", "--capabilities", action="store_true", |
522 | + help="Only output CPU capabilities.") |
523 | + args = parser.parse_args() |
524 | |
525 | - if options.quiet: |
526 | + if args.quiet: |
527 | sys.stdout = open(os.devnull, 'a') |
528 | sys.stderr = open(os.devnull, 'a') |
529 | |
530 | test = CPUScalingTest() |
531 | if not os.path.exists(test.cpufreqDirectory): |
532 | - print "CPU Frequency Scaling not supported" |
533 | + print("CPU Frequency Scaling not supported") |
534 | return 0 |
535 | |
536 | if not test.getSystemCapabilities(): |
537 | parser.error("Failed to get system capabilities") |
538 | |
539 | returnValues = [] |
540 | - if not options.capabilities: |
541 | + if not args.capabilities: |
542 | returnValues.append(test.runUserSpaceTests()) |
543 | returnValues.append(test.runOnDemandTests()) |
544 | returnValues.append(test.runPerformanceTests()) |
Remarkably straightforward!