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

Unified Diff: tools/telemetry/telemetry/web_perf/metrics/memory_timeline.py

Issue 1196253011: [Telemetry] Adding Memory Timeline Metric (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: memory_timeline metric should use IterMemoryDumpEvents Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/web_perf/metrics/memory_timeline.py
diff --git a/tools/telemetry/telemetry/web_perf/metrics/memory_timeline.py b/tools/telemetry/telemetry/web_perf/metrics/memory_timeline.py
new file mode 100644
index 0000000000000000000000000000000000000000..7a33e341ba0bdd9bb59470a919bd23c97c97ed6d
--- /dev/null
+++ b/tools/telemetry/telemetry/web_perf/metrics/memory_timeline.py
@@ -0,0 +1,52 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+
+from telemetry.timeline import memory_dump_event
+from telemetry.value import scalar as scalar_value
+from telemetry.web_perf.metrics import timeline_based_metric
+
+
+REPORTED_METRICS = memory_dump_event.STATS_SUMMARY.keys()
+
+
+class MemoryTimelineMetric(timeline_based_metric.TimelineBasedMetric):
+ """MemoryTimelineMetric reports summary stats from memory dump events."""
+
+ def AddResults(self, model, _renderer_thread, interactions, results):
+ def contained_in(dump, interaction):
+ return interaction.start < dump.start and dump.end < interaction.end
+
+ def with_mmaps_during_interactions(dump):
+ return dump.has_mmaps and any(contained_in(dump, interaction)
+ for interaction in interactions)
+
+ memory_dump_events = model.IterMemoryDumpEvents(reverse=True)
+ try:
+ # We report the latest dump that happened during the interactions.
+ # Assumes that memory dump events are sorted in increasing time order.
+ memory_dump = next(memory_dump
+ for memory_dump in memory_dump_events
+ if with_mmaps_during_interactions(memory_dump))
+ except StopIteration:
+ memory_dump = None
+
+ if memory_dump:
+ stats = memory_dump.GetStatsSummary()
+ none_reason = None
+ logging.info('%s %s', results.current_page, stats)
+ else:
+ # No memory dumps found, return None values for all metrics.
+ stats = dict.fromkeys(REPORTED_METRICS)
+ none_reason = 'No memory dumps found during test interactions'
+ logging.warning('No memory dumps found for %s', results.current_page)
+
+ for name, value in stats.iteritems():
+ results.AddValue(scalar_value.ScalarValue(
+ page=results.current_page,
+ name='memory_infra_' + name,
+ units='bytes',
+ value=value,
+ none_value_reason=none_reason))

Powered by Google App Engine
This is Rietveld 408576698