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

Side by Side Diff: tools/telemetry/telemetry/page_runner.py

Issue 11273081: Adding a test for measuring memory usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review (tonyg, nduca) Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/telemetry/telemetry/page_interaction.py ('k') | tools/telemetry/telemetry/page_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import logging 4 import logging
5 import os 5 import os
6 import time 6 import time
7 import traceback 7 import traceback
8 import urlparse 8 import urlparse
9 import random 9 import random
10 import csv 10 import csv
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 http://goto/read-src-internal, or create a new archive using --record. 66 http://goto/read-src-internal, or create a new archive using --record.
67 """, os.path.relpath(archive_path)) 67 """, os.path.relpath(archive_path))
68 68
69 credentials_path = None 69 credentials_path = None
70 if self.page_set.credentials_path: 70 if self.page_set.credentials_path:
71 credentials_path = os.path.join(self.page_set.base_dir, 71 credentials_path = os.path.join(self.page_set.base_dir,
72 self.page_set.credentials_path) 72 self.page_set.credentials_path)
73 if not os.path.exists(credentials_path): 73 if not os.path.exists(credentials_path):
74 credentials_path = None 74 credentials_path = None
75 75
76 for page in self.page_set:
77 test.CustomizeBrowserOptionsForPage(page, possible_browser.options)
78
76 with possible_browser.Create() as b: 79 with possible_browser.Create() as b:
77 b.credentials.credentials_path = credentials_path 80 b.credentials.credentials_path = credentials_path
78 test.SetUpBrowser(b) 81 test.SetUpBrowser(b)
79 82
80 b.credentials.WarnIfMissingCredentials(self.page_set) 83 b.credentials.WarnIfMissingCredentials(self.page_set)
81 84
82 if not options.test_shuffle and options.test_shuffle_order_file is not\ 85 if not options.test_shuffle and options.test_shuffle_order_file is not\
83 None: 86 None:
84 raise Exception('--test-shuffle-order-file requires --test-shuffle.') 87 raise Exception('--test-shuffle-order-file requires --test-shuffle.')
85 88
86 # Set up a random generator for shuffling the page running order. 89 # Set up a random generator for shuffling the page running order.
87 test_random = random.Random() 90 test_random = random.Random()
88 91
89 b.SetReplayArchivePath(archive_path) 92 b.SetReplayArchivePath(archive_path)
90 with b.ConnectToNthTab(0) as tab: 93 with b.ConnectToNthTab(0) as tab:
91 if options.test_shuffle_order_file is None: 94 if options.test_shuffle_order_file is None:
92 for _ in range(int(options.pageset_repeat)): 95 for _ in range(int(options.pageset_repeat)):
93 if options.test_shuffle: 96 if options.test_shuffle:
94 test_random.shuffle(self.page_set) 97 test_random.shuffle(self.page_set)
95 for page in self.page_set: 98 for page in self.page_set:
96 for _ in range(int(options.page_repeat)): 99 for _ in range(int(options.page_repeat)):
97 self._RunPage(options, page, tab, test, results) 100 self._RunPage(options, page, tab, test, results)
98 else: 101 else:
99 self._ReorderPageSet(options.test_shuffle_order_file) 102 self._ReorderPageSet(options.test_shuffle_order_file)
100 for page in self.page_set: 103 for page in self.page_set:
101 self._RunPage(options, page, tab, test, results) 104 self._RunPage(options, page, tab, test, results)
102 105
103 def _RunPage(self, options, page, tab, test, results): 106 def _RunPage(self, options, page, tab, test, results):
107 if not test.CanRunForPage(page):
108 results.AddSkippedPage(page, 'Test cannot run', '')
109 return
110
104 logging.info('Running %s' % page.url) 111 logging.info('Running %s' % page.url)
105 112
106 page_state = PageState() 113 page_state = PageState()
107 try: 114 try:
108 did_prepare = self.PreparePage(page, tab, page_state, results) 115 did_prepare = self.PreparePage(page, tab, page_state, results)
109 except util.TimeoutException, ex: 116 except util.TimeoutException, ex:
110 logging.warning('TimedOut waiting for reply on %s. This is unusual.', 117 logging.warning('TimedOut waiting for reply on %s. This is unusual.',
111 page.url) 118 page.url)
112 results.AddFailure(page, ex, traceback.format_exc()) 119 results.AddFailure(page, ex, traceback.format_exc())
113 return 120 return
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 self.WaitForPageToLoad(page.wait_for_javascript_expression, tab) 189 self.WaitForPageToLoad(page.wait_for_javascript_expression, tab)
183 190
184 tab.WaitForDocumentReadyStateToBeInteractiveOrBetter() 191 tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
185 return True 192 return True
186 193
187 def CleanUpPage(self, page, tab, page_state): # pylint: disable=R0201 194 def CleanUpPage(self, page, tab, page_state): # pylint: disable=R0201
188 if page.credentials and page_state.did_login: 195 if page.credentials and page_state.did_login:
189 tab.browser.credentials.LoginNoLongerNeeded(tab, page.credentials) 196 tab.browser.credentials.LoginNoLongerNeeded(tab, page.credentials)
190 tab.runtime.Evaluate("""window.chrome && chrome.benchmarking && 197 tab.runtime.Evaluate("""window.chrome && chrome.benchmarking &&
191 chrome.benchmarking.closeConnections()""") 198 chrome.benchmarking.closeConnections()""")
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/page_interaction.py ('k') | tools/telemetry/telemetry/page_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698