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

Unified Diff: chrome/test/functional/perf_endure.py

Issue 9655016: Enable Deep Memory Profiler in perf_endure.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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: chrome/test/functional/perf_endure.py
diff --git a/chrome/test/functional/perf_endure.py b/chrome/test/functional/perf_endure.py
old mode 100644
new mode 100755
index df80e73fdedb323f19f132d46f88c635cc189edb..cbacc6c30b0810be24aa31b1ead54252432ad14d
--- a/chrome/test/functional/perf_endure.py
+++ b/chrome/test/functional/perf_endure.py
@@ -14,6 +14,8 @@ This module accepts the following environment variable inputs:
import logging
import os
import re
+import shutil
+import tempfile
import time
import perf
@@ -23,6 +25,24 @@ import remote_inspector_client
import selenium.common.exceptions
from selenium.webdriver.support.ui import WebDriverWait
+DMPROF_DIR_PATH = os.path.join(os.path.dirname(__file__),
Nirnimesh 2012/04/09 18:46:44 Unless you want these vars to be accessible from o
Dai Mikurube (NOT FULLTIME) 2012/04/13 11:16:49 Done.
+ os.pardir,
+ os.pardir,
+ os.pardir,
+ 'tools',
+ 'deep_memory_profiler')
+
+DMPROF_PATH = os.path.join(DMPROF_DIR_PATH,
+ 'dmprof.py')
+
+# TODO(dmikurube): Need to find an actual running chrome.
+CHROME_BIN_PATH = os.path.join(os.path.dirname(__file__),
+ os.pardir,
+ os.pardir,
+ os.pardir,
+ 'out',
+ 'Debug',
+ 'chrome')
Nirnimesh 2012/04/09 18:46:44 What about non-linux?
Dai Mikurube (NOT FULLTIME) 2012/04/13 11:16:49 Done.
class ChromeEndureBaseTest(perf.BasePerfTest):
"""Implements common functionality for all Chrome Endure tests.
@@ -122,6 +142,9 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
logging.info('Chrome interaction #%d. Time remaining in test: %d sec.' %
(self._iteration_num, remaining_time))
+ if self._iteration_num % 20 == 5:
Dai Mikurube (NOT FULLTIME) 2012/04/09 09:10:40 Temporary trigger.
Nirnimesh 2012/04/09 18:46:44 Add comments / TODO notes.
dennis_jeffrey 2012/04/09 19:12:38 We'll likely want to be able to turn profiling on/
Dai Mikurube (NOT FULLTIME) 2012/04/11 08:44:02 Ah, exactly. Such an option is required. How can
dennis_jeffrey 2012/04/12 00:51:52 Right now it's done through environment variables.
Dai Mikurube (NOT FULLTIME) 2012/04/13 11:16:49 Using an environment variable DEEP_MEMORY_PROFILE_
+ self.HeapProfilerDump('In ChromeEndureControlTest')
+
do_scenario()
self._GetPerformanceStats(
@@ -178,6 +201,8 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
return {
'browser_private_mem': browser_proc_info['working_set_mem']['priv'],
'tab_private_mem': tab_proc_info['working_set_mem']['priv'],
+ 'browser_pid': browser_proc_info['pid'],
dennis_jeffrey 2012/04/09 19:12:38 is this value used anywhere?
Dai Mikurube (NOT FULLTIME) 2012/04/13 11:16:49 No for now. Removed it.
+ 'tab_pid': tab_proc_info['pid'],
}
def _GetPerformanceStats(self, webapp_name, test_description,
@@ -223,6 +248,35 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
logging.info(' V8 memory used: %f KB' % v8_mem_used)
self._v8_mem_used_results.append((elapsed_time, v8_mem_used))
+ # TODO(dmikurube): Add --single in dmprof.py?
dennis_jeffrey 2012/04/09 19:12:38 So in general, a test will periodically call HeapP
Dai Mikurube (NOT FULLTIME) 2012/04/11 08:44:02 I'm in tries-and-errors about that. Dumping may t
+ first_dump = ''
+ print '^%s/endure.%05d.\d+.heap$' % (
Nirnimesh 2012/04/09 18:46:44 Use the right logging call instead of print.
Dai Mikurube (NOT FULLTIME) 2012/04/16 09:43:20 Done.
+ self._deep_tempdir, proc_info['tab_pid'])
+ for filename in sorted(os.listdir(self._deep_tempdir)):
+ if re.match('^%s/endure.%05d.\d+.heap$' % (
Nirnimesh 2012/04/09 18:46:44 use os.path.join() instead of hardcoding /
Dai Mikurube (NOT FULLTIME) 2012/04/16 09:43:20 Done.
+ self._deep_tempdir, proc_info['tab_pid']), filename):
+ first_dump = filename
+ break
+
+ # Test printing.
+ if first_dump:
dennis_jeffrey 2012/04/09 19:12:38 What does it mean for a file to be the "first dump
Dai Mikurube (NOT FULLTIME) 2012/04/11 08:44:02 This is just a test printing, and will be removed
+ print 'First Dump: %s' % first_dump
Nirnimesh 2012/04/09 18:46:44 logging.info()?
Dai Mikurube (NOT FULLTIME) 2012/04/16 09:43:20 Done.
+ else:
+ print 'No Dump!'
+ """
+ with open('%s/endure.%05d.json' % (self._deep_tempdir,
Nirnimesh 2012/04/09 18:46:44 use os.path.join
Dai Mikurube (NOT FULLTIME) 2012/04/13 11:16:49 Done.
+ proc_info['tab_pid']), 'w+') as json_f:
+ p = subprocess.Popen(
Nirnimesh 2012/04/09 18:46:44 use better varname instead of |p|
Dai Mikurube (NOT FULLTIME) 2012/04/11 08:44:02 Good catch. Thanks.
+ '%s --json %s %s %s' % (DMPROF_PATH,
+ CHROME_BIN_PATH,
+ os.path.join(DMPROF_DIR_PATH, 'dmpolicy'),
+ @@@SNAPSHOT@@@),
+ shell=True, stdout=json_f)
+ p.wait()
Nirnimesh 2012/04/09 18:46:44 you won't need this if you use subprocess.call() i
Dai Mikurube (NOT FULLTIME) 2012/04/16 09:43:20 Finally, this script is required to run on backgro
+ """
+
+ # 2) Parse .json (including only the latest snapshot) file here.
+
# Output the results seen so far, to be graphed.
self._OutputPerfGraphValue(
'TotalDOMNodeCount', self._dom_node_count_results, 'nodes',
@@ -244,6 +298,7 @@ class ChromeEndureBaseTest(perf.BasePerfTest):
'V8MemoryUsed', self._v8_mem_used_results, 'KB',
graph_name='%s%s-V8MemUsed' % (webapp_name, test_description),
units_x='seconds')
+ # 3) Do self._OutputPerfGraphValue for multiple lines, here.
def _GetElement(self, find_by, value):
"""Gets a WebDriver element object from the webpage DOM.
@@ -310,6 +365,19 @@ class ChromeEndureControlTest(ChromeEndureBaseTest):
_webapp_name = 'Control'
_tab_title_substring = 'Chrome Endure Control Test'
+ def setUp(self):
dennis_jeffrey 2012/04/09 19:12:38 This only enables profiling in the two control tes
Dai Mikurube (NOT FULLTIME) 2012/04/11 08:44:02 Finally, yes. Is there an efficient way to enable
dennis_jeffrey 2012/04/12 00:51:52 Yes - if you enable profiling above in class Chrom
Dai Mikurube (NOT FULLTIME) 2012/04/13 11:16:49 I see. Thank you. I did it in the uploaded code.
+ # TODO(dmikurube): Have to specify "--no-sandbox" for Chrome.
Dai Mikurube (NOT FULLTIME) 2012/04/09 09:20:27 Note: ExtraChromeFlags would work.
+ self._deep_tempdir = tempfile.mkdtemp()
+ os.environ['HEAPPROFILE'] = '%s/endure' % self._deep_tempdir
Nirnimesh 2012/04/09 18:46:44 os.path.join
Dai Mikurube (NOT FULLTIME) 2012/04/13 11:16:49 Done.
+ os.environ['DEEP_HEAP_PROFILE'] = 'True'
+ ChromeEndureBaseTest.setUp(self)
+
+ def tearDown(self):
+ del os.environ['DEEP_HEAP_PROFILE']
+ del os.environ['HEAPPROFILE']
+ ChromeEndureBaseTest.tearDown(self)
+ # shutil.rmtree(self._deep_tempdir)
+
def testControlAttachDetachDOMTree(self):
"""Continually attach and detach a DOM tree from a basic document."""
test_description = 'AttachDetachDOMTree'
« 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