OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 class Platform(object): | 5 class Platform(object): |
6 """The platform that the target browser is running on. | 6 """The platform that the target browser is running on. |
7 | 7 |
8 Provides a limited interface to obtain stats from the platform itself, where | 8 Provides a limited interface to interact with the platform itself, where |
9 possible. | 9 possible. It's important to note that platforms may not provide a specific |
10 API, so check with IsFooBar() for availability. | |
10 """ | 11 """ |
12 def __init__(self, platform_backend): | |
13 self._platform_backend = platform_backend | |
11 | 14 |
12 def GetSurfaceCollector(self, trace_tag): | 15 def IsRawDisplayFrameRateSupported(self): |
13 """Platforms may be able to collect GL surface stats.""" | 16 """Platforms may be able to collect GL surface stats.""" |
14 class StubSurfaceCollector(object): | 17 return self._platform_backend.IsRawDisplayFrameRateSupported() |
15 def __init__(self, trace_tag): | |
16 pass | |
17 def __enter__(self): | |
18 pass | |
19 def __exit__(self, *args): | |
20 pass | |
21 | 18 |
22 return StubSurfaceCollector(trace_tag) | 19 def StartRawDisplayFrameRateMeasurement(self, trace_tag): |
20 """Start measuring GL surface stats.""" | |
21 return self._platform_backend.StartRawDisplayFrameRateMeasurement(trace_tag) | |
22 | |
23 def StopRawDisplayFrameRateMeasurement(self): | |
24 """Stop measuring GL surface stats and print results.""" | |
25 return self._platform_backend.StopRawDisplayFrameRateMeasurement() | |
26 | |
27 def SetFullPerformanceModeEnabled(self, enabled): | |
28 """Platforms may tweak their CPU governor, system status, etc. | |
29 | |
30 Most platforms can operate in a battery saving mode. While good for battery | |
31 life, this can cause confusing performance results and add noise. Turning | |
32 full performance mode on disables these features, which is useful for | |
33 performance testing. | |
34 """ | |
35 return self._platform_backend.SetFullPerformanceModeEnabled(enabled) | |
36 | |
37 def CanMonitorThermalThrottling(self): | |
38 """Platforms may be able to detect thermal throttling. | |
39 | |
40 Some fan-less computers go into a reduced performance mode when their heat | |
41 exceeds a certain threshold. Performance tests in particular should use this | |
42 API to detect if this has happened and interpret results accordingly. | |
43 """ | |
44 return self._platform_backend.CanMonitorThermalThrottling() | |
45 | |
46 def IsThermallyThrottled(self): | |
aberent
2013/01/29 14:03:36
See comment in android_platform.py
bulach
2013/02/22 11:54:25
Done.
| |
47 """Returns True if the device has been thermally throttled.""" | |
48 return self._platform_backend.IsThermallyThrottled() | |
49 | |
50 | |
51 def EmptyPlatform(): | |
52 class EmptyPlatformBackend(object): | |
53 def IsRawDisplayFrameRateSupported(self): | |
54 return False | |
55 | |
56 def StartRawDisplayFrameRateMeasurement(self, _): | |
57 return NotImplementedError() | |
58 | |
59 def StopRawDisplayFrameRateMeasurement(self): | |
60 return NotImplementedError() | |
61 | |
62 def SetFullPerformanceModeEnabled(self, enabled): | |
63 pass | |
64 | |
65 def CanMonitorThermalThrottling(self): | |
66 return False | |
67 | |
68 def IsThermallyThrottled(self): | |
69 return NotImplementedError() | |
70 | |
71 return Platform(EmptyPlatformBackend()) | |
OLD | NEW |