Index: tools/telemetry/telemetry/core/chrome/platform.py |
diff --git a/tools/telemetry/telemetry/core/chrome/platform.py b/tools/telemetry/telemetry/core/chrome/platform.py |
index c668f7b2a62d402c8dc520da45102130ef8e7235..a528b2f8bd1b25d84ec32683a8d299d682190f3f 100644 |
--- a/tools/telemetry/telemetry/core/chrome/platform.py |
+++ b/tools/telemetry/telemetry/core/chrome/platform.py |
@@ -5,18 +5,74 @@ |
class Platform(object): |
"""The platform that the target browser is running on. |
- Provides a limited interface to obtain stats from the platform itself, where |
- possible. |
+ Provides a limited interface to interact with the platform itself, where |
+ possible. It's important to note that platforms may not provide a specific |
+ API, so check with IsFooBar() for availability. |
""" |
+ def __init__(self, platform_backend): |
achuithb
2013/02/25 21:18:08
This breaks PosssibleCrOSBrowser.Create at line 30
|
+ self._platform_backend = platform_backend |
- def GetSurfaceCollector(self, trace_tag): |
+ def IsRawDisplayFrameRateSupported(self): |
"""Platforms may be able to collect GL surface stats.""" |
- class StubSurfaceCollector(object): |
- def __init__(self, trace_tag): |
- pass |
- def __enter__(self): |
- pass |
- def __exit__(self, *args): |
- pass |
- |
- return StubSurfaceCollector(trace_tag) |
+ return self._platform_backend.IsRawDisplayFrameRateSupported() |
+ |
+ def StartRawDisplayFrameRateMeasurement(self, trace_tag): |
+ """Start measuring GL surface stats.""" |
+ return self._platform_backend.StartRawDisplayFrameRateMeasurement(trace_tag) |
+ |
+ def StopRawDisplayFrameRateMeasurement(self): |
+ """Stop measuring GL surface stats and print results.""" |
+ return self._platform_backend.StopRawDisplayFrameRateMeasurement() |
+ |
+ def SetFullPerformanceModeEnabled(self, enabled): |
+ """Platforms may tweak their CPU governor, system status, etc. |
+ |
+ Most platforms can operate in a battery saving mode. While good for battery |
+ life, this can cause confusing performance results and add noise. Turning |
+ full performance mode on disables these features, which is useful for |
+ performance testing. |
+ """ |
+ return self._platform_backend.SetFullPerformanceModeEnabled(enabled) |
+ |
+ def CanMonitorThermalThrottling(self): |
+ """Platforms may be able to detect thermal throttling. |
+ |
+ Some fan-less computers go into a reduced performance mode when their heat |
+ exceeds a certain threshold. Performance tests in particular should use this |
+ API to detect if this has happened and interpret results accordingly. |
+ """ |
+ return self._platform_backend.CanMonitorThermalThrottling() |
+ |
+ def IsThermallyThrottled(self): |
+ """Returns True if the device is currently thermally throttled.""" |
+ return self._platform_backend.IsThermallyThrottled() |
+ |
+ def HasBeenThermallyThrottled(self): |
+ """Returns True if the device has been thermally throttled.""" |
+ return self._platform_backend.HasBeenThermallyThrottled() |
+ |
+ |
+def EmptyPlatform(): |
+ class EmptyPlatformBackend(object): |
+ def IsRawDisplayFrameRateSupported(self): |
+ return False |
+ |
+ def StartRawDisplayFrameRateMeasurement(self, _): |
+ return NotImplementedError() |
+ |
+ def StopRawDisplayFrameRateMeasurement(self): |
+ return NotImplementedError() |
+ |
+ def SetFullPerformanceModeEnabled(self, enabled): |
+ pass |
+ |
+ def CanMonitorThermalThrottling(self): |
+ return False |
+ |
+ def IsThermallyThrottled(self): |
+ return NotImplementedError() |
+ |
+ def HasBeenThermallyThrottled(self): |
+ return NotImplementedError() |
+ |
+ return Platform(EmptyPlatformBackend()) |