OLD | NEW |
1 # Copyright 2016 Google Inc. | 1 # Copyright 2016 Google Inc. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import time | 6 import time |
7 | 7 |
8 class Hardware: | 8 class Hardware: |
9 """Locks down and monitors hardware for benchmarking. | 9 """Locks down and monitors hardware for benchmarking. |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 def __init__(self): | 23 def __init__(self): |
24 self.warmup_time = 0 | 24 self.warmup_time = 0 |
25 | 25 |
26 def __enter__(self): | 26 def __enter__(self): |
27 return self | 27 return self |
28 | 28 |
29 def __exit__(self, exception_type, exception_value, traceback): | 29 def __exit__(self, exception_type, exception_value, traceback): |
30 pass | 30 pass |
31 | 31 |
| 32 def filter_line(self, line): |
| 33 """Returns False if the provided output line can be suppressed.""" |
| 34 return True |
| 35 |
32 def sanity_check(self): | 36 def sanity_check(self): |
33 """Raises a HardwareException if any hardware state is not as expected.""" | 37 """Raises a HardwareException if any hardware state is not as expected.""" |
34 pass | 38 pass |
35 | 39 |
36 def print_debug_diagnostics(self): | 40 def print_debug_diagnostics(self): |
37 """Prints any info that may help improve or debug hardware monitoring.""" | 41 """Prints any info that may help improve or debug hardware monitoring.""" |
38 pass | 42 pass |
39 | 43 |
40 def sleep(self, sleeptime): | 44 def sleep(self, sleeptime): |
41 """Puts the hardware into a resting state for a fixed amount of time.""" | 45 """Puts the hardware into a resting state for a fixed amount of time.""" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 88 |
85 @staticmethod | 89 @staticmethod |
86 def check_all(expectations, stringvalues): | 90 def check_all(expectations, stringvalues): |
87 if len(stringvalues) != len(expectations): | 91 if len(stringvalues) != len(expectations): |
88 raise Exception("unexpected reading from hardware gauges " | 92 raise Exception("unexpected reading from hardware gauges " |
89 "(expected %i values):\n%s" % | 93 "(expected %i values):\n%s" % |
90 (len(expectations), '\n'.join(stringvalues))) | 94 (len(expectations), '\n'.join(stringvalues))) |
91 | 95 |
92 for value, expected in zip(stringvalues, expectations): | 96 for value, expected in zip(stringvalues, expectations): |
93 expected.check(value) | 97 expected.check(value) |
OLD | NEW |