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

Unified Diff: tools/perf/metrics/v8_object_stats.py

Issue 23112028: [Telemetry] Add support for capturing V8 object stats to Telemetry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stats_table_android
Patch Set: Created 7 years, 4 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/perf/metrics/v8_object_stats.py
diff --git a/tools/perf/metrics/v8_object_stats.py b/tools/perf/metrics/v8_object_stats.py
new file mode 100644
index 0000000000000000000000000000000000000000..db22257ced6f42593b5d56d54ee96dcdf8bf82f2
--- /dev/null
+++ b/tools/perf/metrics/v8_object_stats.py
@@ -0,0 +1,43 @@
+# Copyright 2013 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.
+
+from metrics import Metric
+from metrics import stats_table_util
+
+
+class V8ObjectStatsMetric(Metric):
+ """V8ObjectStatsMetric gathers statistics on the size of types in the V8 heap.
+
+ It does this by enabling the --track_gc_object_stats flag on V8 and reading
+ these statistics from the StatsTableMetric.
+ """
+
+ def __init__(self):
+ super(V8ObjectStatsMetric, self).__init__()
+ self._stats_table = None
+ self._stats_table = None
+
+ @classmethod
+ def CustomizeBrowserOptions(cls, options):
+ options.AppendExtraBrowserArg('--enable-stats-table')
+ options.AppendExtraBrowserArg(
+ '--js-flags=--track_gc_object_stats --expose_gc')
+
+ def Start(self, page, tab):
+ """Do Nothing."""
+
+ def Stop(self, page, tab):
+ """Get the values in the stats table after the page is loaded."""
+ # Trigger GC to ensure stats are checkpointed.
+ tab.EvaluateJavaScript('window.gc()')
+ self._stats_table = stats_table_util.GetStatsTable(tab)
+
+ def AddResults(self, tab, results):
+ """Add results for this page to the results object."""
+ assert self._stats_table, 'Must call Stop() first'
+ for stat_name in self._stats_table:
+ if ("V8:OsMemoryAllocated" in stat_name or
+ "V8:SizeOf_" in stat_name or
+ "V8:Memory" in stat_name):
+ results.Add(stat_name, 'kb', self._stats_table[stat_name] / 1024.0)
« content/renderer/stats_collection_controller.h ('K') | « tools/perf/metrics/stats_table_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698