9 """Locks down and monitors hardware for benchmarking.
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
13 benchmarking mode
for the duration of a
'with' block. e.g.:
18 While benchmarking, the caller must call
sanity_check() frequently to verify
19 the hardware state has
not changed.
29 def __exit__(self, exception_type, exception_value, traceback):
33 """Returns False if the provided output line can be suppressed."""
37 """Raises a HardwareException if any hardware state is not as expected."""
41 """Prints any info that may help improve or debug hardware monitoring."""
45class HardwareException(Exception):
46 """Gets thrown when certain hardware state is not what we expect.
48 Generally this happens because of thermal conditions or other variables beyond
49 our control,
and the appropriate course of action
is to take a short nap
50 before resuming the benchmark.
55 Exception.__init__(self, message)
60 """Simple helper for checking the readings on hardware gauges."""
61 def __init__(self, value_type, min_value=None, max_value=None,
62 exact_value=None, name=None, sleeptime=60):
87 if len(stringvalues) !=
len(expectations):
88 raise Exception(
"unexpected reading from hardware gauges "
89 "(expected %i values):\n%s" %
90 (
len(expectations),
'\n'.
join(stringvalues)))
92 for value, expected
in zip(stringvalues, expectations):
static SkString join(const CommandLineFlags::StringArray &)
static void run_benchmark(GrDirectContext *context, sk_sp< SkSurface > surface, SkpProducer *skpp, std::vector< Sample > *samples)