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

Side by Side Diff: chrome/test/functional/perf_endure.py

Issue 11368097: Apply other policies of Deep Memory Profiler in Chrome Endure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Performance tests for Chrome Endure (long-running perf tests on Chrome). 6 """Performance tests for Chrome Endure (long-running perf tests on Chrome).
7 7
8 This module accepts the following environment variable inputs: 8 This module accepts the following environment variable inputs:
9 TEST_LENGTH: The number of seconds in which to run each test. 9 TEST_LENGTH: The number of seconds in which to run each test.
10 PERF_STATS_INTERVAL: The number of seconds to wait in-between each sampling 10 PERF_STATS_INTERVAL: The number of seconds to wait in-between each sampling
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 class DeepMemoryProfiler(object): 48 class DeepMemoryProfiler(object):
49 """Controls Deep Memory Profiler (dmprof) for endurance tests.""" 49 """Controls Deep Memory Profiler (dmprof) for endurance tests."""
50 DEEP_MEMORY_PROFILE = False 50 DEEP_MEMORY_PROFILE = False
51 DEEP_MEMORY_PROFILE_SAVE = False 51 DEEP_MEMORY_PROFILE_SAVE = False
52 52
53 _DMPROF_DIR_PATH = os.path.join( 53 _DMPROF_DIR_PATH = os.path.join(
54 os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, 54 os.path.dirname(__file__), os.pardir, os.pardir, os.pardir,
55 'tools', 'deep_memory_profiler') 55 'tools', 'deep_memory_profiler')
56 _DMPROF_SCRIPT_PATH = os.path.join(_DMPROF_DIR_PATH, 'dmprof') 56 _DMPROF_SCRIPT_PATH = os.path.join(_DMPROF_DIR_PATH, 'dmprof')
57 _POLICIES = ['l0', 'l1', 'l2', 't0']
57 58
58 def __init__(self): 59 def __init__(self):
59 self._enabled = self.GetEnvironmentVariable( 60 self._enabled = self.GetEnvironmentVariable(
60 'DEEP_MEMORY_PROFILE', bool, self.DEEP_MEMORY_PROFILE) 61 'DEEP_MEMORY_PROFILE', bool, self.DEEP_MEMORY_PROFILE)
61 self._save = self.GetEnvironmentVariable( 62 self._save = self.GetEnvironmentVariable(
62 'DEEP_MEMORY_PROFILE_SAVE', bool, self.DEEP_MEMORY_PROFILE_SAVE) 63 'DEEP_MEMORY_PROFILE_SAVE', bool, self.DEEP_MEMORY_PROFILE_SAVE)
63 self._json_file = None 64 self._json_file = None
64 self._last_json_filename = '' 65 self._last_json_filename = ''
65 self._proc = None 66 self._proc = None
66 self._last_time = -1.0 67 self._last_time = {}
68 for policy in self._POLICIES:
69 self._last_time[policy] = -1.0
67 70
68 def __nonzero__(self): 71 def __nonzero__(self):
69 return self._enabled 72 return self._enabled
70 73
71 @staticmethod 74 @staticmethod
72 def GetEnvironmentVariable(env_name, converter, default): 75 def GetEnvironmentVariable(env_name, converter, default):
73 """Returns a converted environment variable for Deep Memory Profiler. 76 """Returns a converted environment variable for Deep Memory Profiler.
74 77
75 Args: 78 Args:
76 env_name: A string name of an environment variable. 79 env_name: A string name of an environment variable.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 else: 175 else:
173 logging.info(' No dump files.') 176 logging.info(' No dump files.')
174 177
175 def ParseResultAndOutputPerfGraphValues( 178 def ParseResultAndOutputPerfGraphValues(
176 self, webapp_name, test_description, output_perf_graph_value): 179 self, webapp_name, test_description, output_perf_graph_value):
177 """Parses Deep Memory Profiler result, and outputs perf graph values.""" 180 """Parses Deep Memory Profiler result, and outputs perf graph values."""
178 if not self._enabled: 181 if not self._enabled:
179 return 182 return
180 183
181 results = {} 184 results = {}
182 if self._last_json_filename: 185 for policy in self._POLICIES:
183 json_data = {} 186 if self._last_json_filename:
184 with open(self._last_json_filename) as json_f: 187 json_data = {}
185 json_data = json.load(json_f) 188 with open(self._last_json_filename) as json_f:
186 if json_data['version'] == 'JSON_DEEP_1': 189 json_data = json.load(json_f)
187 results = json_data['snapshots'] 190 if json_data['version'] == 'JSON_DEEP_1':
188 elif json_data['version'] == 'JSON_DEEP_2': 191 results[policy] = json_data['snapshots']
189 results = json_data['policies']['l2']['snapshots'] 192 elif json_data['version'] == 'JSON_DEEP_2':
190 if results and results[-1]['second'] > self._last_time: 193 results[policy] = json_data['policies'][policy]['snapshots']
191 started = False 194 for policy, result in results.iteritems():
192 for legend in json_data['policies']['l2']['legends']: 195 if result and result[-1]['second'] > self._last_time[policy]:
193 if legend == 'FROM_HERE_FOR_TOTAL': 196 started = False
194 started = True 197 for legend in json_data['policies'][policy]['legends']:
195 elif legend == 'UNTIL_HERE_FOR_TOTAL': 198 if legend == 'FROM_HERE_FOR_TOTAL':
196 break 199 started = True
197 elif started: 200 elif legend == 'UNTIL_HERE_FOR_TOTAL':
198 output_perf_graph_value( 201 break
199 legend.encode('utf-8'), [ 202 elif started:
200 (int(round(snapshot['second'])), snapshot[legend] / 1024) 203 output_perf_graph_value(
201 for snapshot in results 204 legend.encode('utf-8'), [
202 if snapshot['second'] > self._last_time], 205 (int(round(snapshot['second'])), snapshot[legend] / 1024)
203 'KB', 206 for snapshot in result
204 graph_name='%s%s-DMP' % (webapp_name, test_description), 207 if snapshot['second'] > self._last_time[policy]],
205 units_x='seconds', is_stacked=True) 208 'KB',
206 self._last_time = results[-1]['second'] 209 graph_name='%s%s-%s-DMP' % (
210 webapp_name, test_description, policy),
211 units_x='seconds', is_stacked=True)
212 self._last_time[policy] = result[-1]['second']
207 213
208 def _WaitForDeepMemoryProfiler(self): 214 def _WaitForDeepMemoryProfiler(self):
209 """Waits for the Deep Memory Profiler to finish if running.""" 215 """Waits for the Deep Memory Profiler to finish if running."""
210 if not self._enabled or not self._proc: 216 if not self._enabled or not self._proc:
211 return 217 return
212 218
213 self._proc.wait() 219 self._proc.wait()
214 self._proc = None 220 self._proc = None
215 if self._json_file: 221 if self._json_file:
216 self._last_json_filename = self._json_file.name 222 self._last_json_filename = self._json_file.name
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 if not os.path.exists(scripts): 1249 if not os.path.exists(scripts):
1244 raise IOError('Injected scripts %s not found.' % scripts) 1250 raise IOError('Injected scripts %s not found.' % scripts)
1245 replay_options = ['--inject_scripts', scripts] 1251 replay_options = ['--inject_scripts', scripts]
1246 if 'WPR_RECORD' in os.environ: 1252 if 'WPR_RECORD' in os.environ:
1247 replay_options.append('--append') 1253 replay_options.append('--append')
1248 return webpagereplay.ReplayServer(archive_path, replay_options) 1254 return webpagereplay.ReplayServer(archive_path, replay_options)
1249 1255
1250 1256
1251 if __name__ == '__main__': 1257 if __name__ == '__main__':
1252 pyauto_functional.Main() 1258 pyauto_functional.Main()
OLDNEW
« 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