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

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

Issue 23961002: Adding V8 and process memory information as metrics that endure tracks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/measurements/endure.py
diff --git a/tools/perf/measurements/endure.py b/tools/perf/measurements/endure.py
index 9cf4e75b482d1a2da1edaa5bdb64454b19d12d21..7389ac0cdaf681a0f8453df2d6960cea408a42f3 100644
--- a/tools/perf/measurements/endure.py
+++ b/tools/perf/measurements/endure.py
@@ -2,16 +2,42 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from metrics import v8_object_stats
from telemetry.page import page_measurement
import optparse
import time
+_V8_BYTES_COMMITED = [
+ 'V8.MemoryNewSpaceBytesCommitted',
+ 'V8.MemoryOldPointerSpaceBytesCommitted',
+ 'V8.MemoryOldDataSpaceBytesCommitted',
+ 'V8.MemoryCodeSpaceBytesCommitted',
+ 'V8.MemoryMapSpaceBytesCommitted',
+ 'V8.MemoryCellSpaceBytesCommitted',
+ 'V8.MemoryPropertyCellSpaceBytesCommitted',
+ 'V8.MemoryLoSpaceBytesCommitted'
+]
+_V8_BYTES_USED = [
+ 'V8.MemoryNewSpaceBytesUsed',
+ 'V8.MemoryOldPointerSpaceBytesUsed',
+ 'V8.MemoryOldDataSpaceBytesUsed',
+ 'V8.MemoryCodeSpaceBytesUsed',
+ 'V8.MemoryMapSpaceBytesUsed',
+ 'V8.MemoryCellSpaceBytesUsed',
+ 'V8.MemoryPropertyCellSpaceBytesUsed',
+ 'V8.MemoryLoSpaceBytesUsed'
+]
+_V8_MEMORY_ALLOCATED = [
+ 'V8.OsMemoryAllocated'
+]
class Endure(page_measurement.PageMeasurement):
def __init__(self):
super(Endure, self).__init__('endure')
+ self._browser = None
self._test_start_time = None
+ self._v8_object_stats_metric = None
# Timestamp of the last memory retrieval.
self._last_mem_dump = 0
@@ -25,6 +51,17 @@ class Endure(page_measurement.PageMeasurement):
help='Time interval between perf dumps (secs)')
parser.add_option_group(group)
+ def DidStartBrowser(self, browser):
+ # Save the browser for memory_stats.
+ self._browser = browser
+ self._v8_object_stats_metric = v8_object_stats.V8ObjectStatsMetric()
+
+ def CustomizeBrowserOptions(self, options):
+ # TODO(edmundyan): Remove --no-sandbox once v8_object_stats can run
+ # independetly
+ options.AppendExtraBrowserArg('--no-sandbox')
tonyg 2013/09/04 17:47:38 If the metric needs this, the metric should be res
edmundyan 2013/09/05 20:32:11 Done.
+ v8_object_stats.V8ObjectStatsMetric.CustomizeBrowserOptions(options)
+
def CanRunForPage(self, page):
return hasattr(page, 'endure')
@@ -37,26 +74,70 @@ class Endure(page_measurement.PageMeasurement):
now = time.time()
if int(round(now - self._last_mem_dump)) > self.options.perf_stats_interval:
self._last_mem_dump = now
- self._GetPerformanceStats(tab, results, now)
+ self._GetPerformanceStats(page, tab, results, now)
- def _GetPerformanceStats(self, tab, results, now):
+ def _GetPerformanceStats(self, page, tab, results, now):
"""Record all memory information."""
elapsed_time = int(round(now - self._test_start_time))
+ # Grab all metrics at the beginning
+ _dom_stats = tab.dom_stats
tonyg 2013/09/04 17:47:38 No need to _ prefix local variables.
edmundyan 2013/09/05 20:32:11 Done.
+ _memory_stats = self._browser.memory_stats
+ self._v8_object_stats_metric.Stop(page, tab)
+ _v8_info = self._v8_object_stats_metric._results
+
+
# DOM Nodes
- dom_node_count = tab.dom_stats['node_count']
+ dom_node_count = _dom_stats['node_count']
self._SaveToResults(results, 'TotalDOMNodeCount_X',
'seconds', elapsed_time)
self._SaveToResults(results, 'TotalDOMNodeCount_Y',
'nodes', dom_node_count)
# Event Listeners
- event_listener_count = tab.dom_stats['event_listener_count']
+ event_listener_count = _dom_stats['event_listener_count']
self._SaveToResults(results, 'EventListenerCount_X',
'seconds', elapsed_time)
self._SaveToResults(results, 'EventListenerCount_Y',
'listeners', event_listener_count)
+ # Memory stats
+ browser_vm = _memory_stats['Browser'].get('VM', 0) / 1024.0
+ self._SaveToResults(results, 'BrowserVirtualMemory_X',
+ 'seconds', elapsed_time)
+ self._SaveToResults(results, 'BrowserVirtualMemory_Y',
+ 'KB', browser_vm)
+ renderer_vm = _memory_stats['Renderer'].get('VM', 0) / 1024.0
+ self._SaveToResults(results, 'RendererVirtualMemory_X',
+ 'seconds', elapsed_time)
+ self._SaveToResults(results, 'RendererVirtualMemory_Y',
+ 'KB', renderer_vm)
+
+ # V8 stats
+ v8_bytes_commited = self._SumDictFromKeys(_v8_info,
+ _V8_BYTES_COMMITED) / 1024.0
+ self._SaveToResults(results, 'V8BytesCommited_X',
+ 'seconds', elapsed_time)
+ self._SaveToResults(results, 'V8BytesCommited_Y',
+ 'KB', v8_bytes_commited)
+
+ v8_bytes_used = self._SumDictFromKeys(_v8_info,
+ _V8_BYTES_USED) / 1024.0
+ self._SaveToResults(results, 'V8BytesUsed_X',
+ 'seconds', elapsed_time)
+ self._SaveToResults(results, 'V8BytesUsed_Y',
+ 'KB', v8_bytes_used)
+
+ v8_mem_allocated = self._SumDictFromKeys(_v8_info,
+ _V8_MEMORY_ALLOCATED) / 1024.0
+ self._SaveToResults(results, 'V8MemoryAllocated_X',
+ 'seconds', elapsed_time)
+ self._SaveToResults(results, 'V8MemoryAllocated_Y',
+ 'KB', v8_mem_allocated)
+
+ def _SumDictFromKeys(self, d, keys_list):
+ return sum([v for k, v in d.iteritems() if k in keys_list])
Michael Achenbach 2013/09/05 11:57:23 How about: [d[k] for k in keys_list] or can there
edmundyan 2013/09/05 20:32:11 There won't be missing keys. If v8 can't find the
+
def _SaveToResults(self, results, trace_name, units, value,
chart_name=None, data_type='default'):
results.Add(trace_name, units, value, chart_name, data_type)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698