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

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

Issue 2410373002: skpbench: add warmup run (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
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 @staticmethod 85 @staticmethod
86 def check_all(expectations, stringvalues): 86 def check_all(expectations, stringvalues):
87 if len(stringvalues) != len(expectations): 87 if len(stringvalues) != len(expectations):
88 raise Exception("unexpected reading from hardware gauges " 88 raise Exception("unexpected reading from hardware gauges "
89 "(expected %i values):\n%s" % 89 "(expected %i values):\n%s" %
90 (len(expectations), '\n'.join(stringvalues))) 90 (len(expectations), '\n'.join(stringvalues)))
91 91
92 for value, expected in zip(stringvalues, expectations): 92 for value, expected in zip(stringvalues, expectations):
93 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