| Index: telemetry/telemetry/internal/actions/action_runner.py
|
| diff --git a/telemetry/telemetry/internal/actions/action_runner.py b/telemetry/telemetry/internal/actions/action_runner.py
|
| index 19dc78ec1782fc15c6f2a0e5d9c124e66b983a61..f51f6a3ff1562d092095a29f82ad9eeef9ddf0ac 100644
|
| --- a/telemetry/telemetry/internal/actions/action_runner.py
|
| +++ b/telemetry/telemetry/internal/actions/action_runner.py
|
| @@ -28,6 +28,9 @@ from telemetry.internal.actions.wait import WaitForElementAction
|
| from telemetry.web_perf import timeline_interaction_record
|
|
|
|
|
| +_DUMP_WAIT_TIME = 3
|
| +
|
| +
|
| class ActionRunner(object):
|
|
|
| def __init__(self, tab, skip_waits=False):
|
| @@ -104,6 +107,30 @@ class ActionRunner(object):
|
| """
|
| return self.CreateInteraction('Gesture_' + label, repeatable)
|
|
|
| + def MeasureMemory(self, deterministic_mode=False):
|
| + """Add a memory measurement to the trace being recorded.
|
| +
|
| + Behaves as a no-op if tracing is not enabled.
|
| +
|
| + TODO(perezju): Also behave as a no-op if tracing is enabled but
|
| + memory-infra is not.
|
| +
|
| + Args:
|
| + deterministic_mode: A boolean indicating whether to attempt or not to
|
| + control the environment (force GCs, clear caches) before making the
|
| + measurement in an attempt to obtain more deterministic results.
|
| + """
|
| + platform = self.tab.browser.platform
|
| + if not platform.tracing_controller.is_tracing_running:
|
| + logging.warning('Tracing is off. No memory dumps are being recorded.')
|
| + return
|
| + if deterministic_mode:
|
| + self.Wait(_DUMP_WAIT_TIME)
|
| + self.ForceGarbageCollection()
|
| + platform.FlushEntireSystemCache()
|
| + self.Wait(_DUMP_WAIT_TIME)
|
| + assert self.tab.browser.DumpMemory(), 'Unable to obtain memory dump'
|
| +
|
| def Navigate(self, url, script_to_evaluate_on_commit=None,
|
| timeout_in_seconds=60):
|
| """Navigates to |url|.
|
|
|