Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: tools/skpbench/_hardware.py

Issue 2408893002: skpbench: add debug prints for thermal trip points (Closed)
Patch Set: skpbench: add warmup run Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/skpbench/_hardware_android.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 This is a common base for classes that can control the specific hardware 11 This is a common base for classes that can control the specific hardware
12 we are running on. Its purpose is to lock the hardware into a constant 12 we are running on. Its purpose is to lock the hardware into a constant
13 benchmarking mode for the duration of a 'with' block. e.g.: 13 benchmarking mode for the duration of a 'with' block. e.g.:
14 14
15 with hardware: 15 with hardware:
16 run_benchmark() 16 run_benchmark()
17 17
18 While benchmarking, the caller must call sanity_check() frequently to verify 18 While benchmarking, the caller must call sanity_check() frequently to verify
19 the hardware state has not changed. 19 the hardware state has not changed.
20 20
21 """ 21 """
22 22
23 def __init__(self): 23 def __init__(self):
24 self.kick_in_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 sanity_check(self): 32 def sanity_check(self):
33 """Raises a HardwareException if any hardware state is not as expected.""" 33 """Raises a HardwareException if any hardware state is not as expected."""
34 pass 34 pass
35 35
36 def print_debug_diagnostics(self):
37 """Prints any info that may help improve or debug hardware monitoring."""
38 pass
39
36 def sleep(self, sleeptime): 40 def sleep(self, sleeptime):
37 """Puts the hardware into a resting state for a fixed amount of time.""" 41 """Puts the hardware into a resting state for a fixed amount of time."""
38 time.sleep(sleeptime) 42 time.sleep(sleeptime)
39 43
40 44
41 class HardwareException(Exception): 45 class HardwareException(Exception):
42 """Gets thrown when certain hardware state is not what we expect. 46 """Gets thrown when certain hardware state is not what we expect.
43 47
44 Generally this happens because of thermal conditions or other variables beyond 48 Generally this happens because of thermal conditions or other variables beyond
45 our control, and the appropriate course of action is to take a short nap 49 our control, and the appropriate course of action is to take a short nap
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 84
81 @staticmethod 85 @staticmethod
82 def check_all(expectations, stringvalues): 86 def check_all(expectations, stringvalues):
83 if len(stringvalues) != len(expectations): 87 if len(stringvalues) != len(expectations):
84 raise Exception("unexpected reading from hardware gauges " 88 raise Exception("unexpected reading from hardware gauges "
85 "(expected %i values):\n%s" % 89 "(expected %i values):\n%s" %
86 (len(expectations), '\n'.join(stringvalues))) 90 (len(expectations), '\n'.join(stringvalues)))
87 91
88 for value, expected in zip(stringvalues, expectations): 92 for value, expected in zip(stringvalues, expectations):
89 expected.check(value) 93 expected.check(value)
OLDNEW
« no previous file with comments | « no previous file | tools/skpbench/_hardware_android.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698