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

Unified Diff: tools/perf/measurements/renderer_memory.py

Issue 1266833004: telemetry: Add a page set for blink's memory usage measurement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review Created 5 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
« no previous file with comments | « tools/perf/benchmarks/renderer_memory.py ('k') | tools/perf/page_sets/blink_memory_mobile.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/measurements/renderer_memory.py
diff --git a/tools/perf/measurements/renderer_memory.py b/tools/perf/measurements/renderer_memory.py
new file mode 100644
index 0000000000000000000000000000000000000000..243bf107a71fe67d19012c113cb33d1e5be6a91f
--- /dev/null
+++ b/tools/perf/measurements/renderer_memory.py
@@ -0,0 +1,72 @@
+# 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.
+
+from telemetry.page import page_test
+from telemetry.timeline import tracing_category_filter
+from telemetry.timeline import tracing_options
+from telemetry.timeline.model import TimelineModel
+from telemetry.value import scalar
+
+
+class RendererMemory(page_test.PageTest):
+ def __init__(self):
+ super(RendererMemory, self).__init__()
+
+ def WillNavigateToPage(self, page, tab):
+ category_filter = tracing_category_filter.TracingCategoryFilter(
+ '-*,blink.console,disabled-by-default-memory-infra')
petrcermak 2015/08/26 08:20:18 This should be indented 4 spaces (+2)
bashi 2015/08/26 08:57:34 Done.
+ options = tracing_options.TracingOptions()
+ options.enable_chrome_trace = True
+ tab.browser.platform.tracing_controller.Start(options, category_filter, 10)
+
+ def CustomizeBrowserOptions(self, options):
+ options.AppendExtraBrowserArgs(
+ ['--enable-memory-benchmarking', '--ignore-certificate-errors',
petrcermak 2015/08/26 08:20:18 This and the next line should be indented 4 spaces
bashi 2015/08/26 08:57:34 Done.
+ '--no-sandbox'])
+
+ def CleanUpAfterPage(self, _, tab):
+ if tab.browser.platform.tracing_controller.is_tracing_running:
+ tab.browser.platform.tracing_controller.Stop()
+
+ def ValidateAndMeasurePage(self, _, tab, results):
+ assert tab.browser.supports_memory_dumping
petrcermak 2015/08/26 08:20:18 Any chance this could be replaced with a decorator
bashi 2015/08/26 08:57:34 I didn't know that. Thanks! Done.
+ guid = tab.browser.DumpMemory()
+ timeline_data = tab.browser.platform.tracing_controller.Stop()
+ timeline_model = TimelineModel(timeline_data)
+ assert guid is not None
petrcermak 2015/08/26 08:20:18 No reason not to put this right after line 34.
bashi 2015/08/26 08:57:34 Done.
+ renderer_process = timeline_model.GetRendererProcessFromTabId(tab.id)
+ assert renderer_process is not None
+ dump = self._FindRendererDump(
+ timeline_model, guid, renderer_process.pid)
petrcermak 2015/08/26 08:20:18 This should be indented 4 spaces (+2)
bashi 2015/08/26 08:57:34 Done.
+ self._AddAllocatorResults(dump, results)
+
+ def _FindRendererDump(self, timeline_model, guid, pid):
+ memory_dumps = list(timeline_model.IterGlobalMemoryDumps())
+ assert len(memory_dumps) == 1
+ assert memory_dumps[0].dump_id == guid
+ renderer_dumps = [
+ dump for dump in memory_dumps[0].IterProcessMemoryDumps()
petrcermak 2015/08/26 08:20:18 This and the next line should be indented 4 spaces
bashi 2015/08/26 08:57:34 Done.
+ if dump.process.pid == pid]
+ assert len(renderer_dumps) == 1
+ return renderer_dumps[0]
+
+ def _AddAllocatorResults(self, dump, results):
+ usage = dump.GetMemoryUsage()
+ def _AddAllocatorStats(category):
petrcermak 2015/08/26 08:20:18 nit: I think it would be more readable if you put
bashi 2015/08/26 08:57:34 Done.
+ results.AddValue(scalar.ScalarValue(
+ results.current_page, category, 'MiB',
petrcermak 2015/08/26 08:20:18 Lines 58-60 and also 69-71 should be indented 4 sp
bashi 2015/08/26 08:57:33 Done.
+ float(usage.get('allocator_' + category, 0.0)) / 1024**2,
+ description='Total memory allocated by ' + category))
+ _AddAllocatorStats('malloc')
+ _AddAllocatorStats('v8')
+ _AddAllocatorStats('blink_gc')
+ _AddAllocatorStats('partition_alloc')
+ _AddAllocatorStats('discardable')
+
+ def _AddMMapStats(category):
+ results.AddValue(scalar.ScalarValue(
+ results.current_page, category, 'MiB',
+ float(usage.get('mmaps_' + category, 0.0)) / 1024**2,
+ description=category))
+ _AddMMapStats('private_dirty')
« no previous file with comments | « tools/perf/benchmarks/renderer_memory.py ('k') | tools/perf/page_sets/blink_memory_mobile.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698