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

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

Issue 10871038: Dump data for stacked graphs in Chrome Endure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: renamed Created 8 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 unified diff | Download patch | Annotate | Revision Log
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 """Basic pyauto performance tests. 6 """Basic pyauto performance tests.
7 7
8 For tests that need to be run for multiple iterations (e.g., so that average 8 For tests that need to be run for multiple iterations (e.g., so that average
9 and standard deviation values can be reported), the default number of iterations 9 and standard deviation values can be reported), the default number of iterations
10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|. 10 run for each of these tests is specified by |_DEFAULT_NUM_ITERATIONS|.
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 times, in milliseconds as a float. 249 times, in milliseconds as a float.
250 """ 250 """
251 assert callable(python_command) 251 assert callable(python_command)
252 def RunCommand(): 252 def RunCommand():
253 for _ in range(num_invocations): 253 for _ in range(num_invocations):
254 python_command() 254 python_command()
255 timer = timeit.Timer(stmt=RunCommand) 255 timer = timeit.Timer(stmt=RunCommand)
256 return timer.timeit(number=1) * 1000 # Convert seconds to milliseconds. 256 return timer.timeit(number=1) * 1000 # Convert seconds to milliseconds.
257 257
258 def _OutputPerfForStandaloneGraphing(self, graph_name, description, value, 258 def _OutputPerfForStandaloneGraphing(self, graph_name, description, value,
259 units, units_x): 259 units, units_x, is_stacked):
260 """Outputs perf measurement data to a local folder to be graphed. 260 """Outputs perf measurement data to a local folder to be graphed.
261 261
262 This function only applies to Chrome desktop, and assumes that environment 262 This function only applies to Chrome desktop, and assumes that environment
263 variable 'LOCAL_PERF_DIR' has been specified and refers to a valid directory 263 variable 'LOCAL_PERF_DIR' has been specified and refers to a valid directory
264 on the local machine. 264 on the local machine.
265 265
266 Args: 266 Args:
267 graph_name: A string name for the graph associated with this performance 267 graph_name: A string name for the graph associated with this performance
268 value. 268 value.
269 description: A string description of the performance value. Should not 269 description: A string description of the performance value. Should not
270 include spaces. 270 include spaces.
271 value: Either a single numeric value representing a performance 271 value: Either a single numeric value representing a performance
272 measurement, or else a list of (x, y) tuples representing one or more 272 measurement, or else a list of (x, y) tuples representing one or more
273 long-running performance measurements, where 'x' is an x-axis value 273 long-running performance measurements, where 'x' is an x-axis value
274 (such as an iteration number) and 'y' is the corresponding performance 274 (such as an iteration number) and 'y' is the corresponding performance
275 measurement. If a list of tuples is given, then the |units_x| 275 measurement. If a list of tuples is given, then the |units_x|
276 argument must also be specified. 276 argument must also be specified.
277 units: A string representing the units of the performance measurement(s). 277 units: A string representing the units of the performance measurement(s).
278 Should not include spaces. 278 Should not include spaces.
279 units_x: A string representing the units of the x-axis values associated 279 units_x: A string representing the units of the x-axis values associated
280 with the performance measurements, such as 'iteration' if the x values 280 with the performance measurements, such as 'iteration' if the x values
281 are iteration numbers. If this argument is specified, then the 281 are iteration numbers. If this argument is specified, then the
282 |value| argument must be a list of (x, y) tuples. 282 |value| argument must be a list of (x, y) tuples.
283 is_stacked: True to draw a "stacked" graph. First-come values are
284 stacked at bottom by default.
283 """ 285 """
284 revision_num_file = os.path.join(self._local_perf_dir, 'last_revision.dat') 286 revision_num_file = os.path.join(self._local_perf_dir, 'last_revision.dat')
285 if os.path.exists(revision_num_file): 287 if os.path.exists(revision_num_file):
286 with open(revision_num_file) as f: 288 with open(revision_num_file) as f:
287 revision = int(f.read()) 289 revision = int(f.read())
288 else: 290 else:
289 revision = 0 291 revision = 0
290 292
291 if not self._seen_graph_lines: 293 if not self._seen_graph_lines:
292 # We're about to output data for a new test run. 294 # We're about to output data for a new test run.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if not description in new_line['traces']: 341 if not description in new_line['traces']:
340 new_line['traces'][description] = [] 342 new_line['traces'][description] = []
341 for x_value, y_value in value: 343 for x_value, y_value in value:
342 new_line['traces'][description].append([str(x_value), str(y_value)]) 344 new_line['traces'][description].append([str(x_value), str(y_value)])
343 else: 345 else:
344 new_line = { 346 new_line = {
345 'rev': revision, 347 'rev': revision,
346 'traces': { description: [str(value), str(0.0)] } 348 'traces': { description: [str(value), str(0.0)] }
347 } 349 }
348 350
351 if is_stacked:
352 new_line['stacked'] = True
353 if 'default_stacking_order' not in new_line:
dennis_jeffrey 2012/09/05 17:34:12 should we change the name to something shorter lik
Dai Mikurube (NOT FULLTIME) 2012/09/06 05:30:10 Renamed: 'stacked' => 'stack' 'default_stacking_or
354 new_line['default_stacking_order'] = []
355 if description not in new_line['default_stacking_order']:
356 new_line['default_stacking_order'].append(description)
357
349 if seen_key in self._seen_graph_lines: 358 if seen_key in self._seen_graph_lines:
350 # Update results for the most recent revision. 359 # Update results for the most recent revision.
351 existing_lines[0] = new_line 360 existing_lines[0] = new_line
352 else: 361 else:
353 # New results for a new revision. 362 # New results for a new revision.
354 existing_lines.insert(0, new_line) 363 existing_lines.insert(0, new_line)
355 self._seen_graph_lines[seen_key] = True 364 self._seen_graph_lines[seen_key] = True
356 365
357 existing_lines = map(str, existing_lines) 366 existing_lines = map(str, existing_lines)
358 with open(data_file, 'w') as f: 367 with open(data_file, 'w') as f:
359 f.write('\n'.join(existing_lines)) 368 f.write('\n'.join(existing_lines))
360 os.chmod(data_file, 0755) 369 os.chmod(data_file, 0755)
361 370
362 with open(revision_num_file, 'w') as f: 371 with open(revision_num_file, 'w') as f:
363 f.write(str(revision)) 372 f.write(str(revision))
364 373
365 def _OutputPerfGraphValue(self, description, value, units, 374 def _OutputPerfGraphValue(self, description, value, units,
dennis_jeffrey 2012/09/05 17:34:12 Note: there are actually 2 ways in which perf resu
Dai Mikurube (NOT FULLTIME) 2012/09/06 05:30:10 Thanks for your effort to commit the "RESULT" pars
cmp_google 2012/09/14 04:32:36 Dennis and Dai, please let me know if/when there's
Dai Mikurube (NOT FULLTIME) 2012/09/14 10:19:07 Ah, ok, I'll Cc: you for such changes!
dennis_jeffrey 2012/09/14 16:33:31 Yes, actually I was planning to make you our main
366 graph_name, units_x=None): 375 graph_name, units_x=None, is_stacked=False):
367 """Outputs a performance value to have it graphed on the performance bots. 376 """Outputs a performance value to have it graphed on the performance bots.
368 377
369 The output format differs, depending on whether the current platform is 378 The output format differs, depending on whether the current platform is
370 Chrome desktop or ChromeOS. 379 Chrome desktop or ChromeOS.
371 380
372 For ChromeOS, the performance bots have a 30-character limit on the length 381 For ChromeOS, the performance bots have a 30-character limit on the length
373 of the key associated with a performance value. A key on ChromeOS is 382 of the key associated with a performance value. A key on ChromeOS is
374 considered to be of the form "units_description" (for example, 383 considered to be of the form "units_description" (for example,
375 "milliseconds_NewTabPage"), and is created from the |units| and 384 "milliseconds_NewTabPage"), and is created from the |units| and
376 |description| passed as input to this function. Any characters beyond the 385 |description| passed as input to this function. Any characters beyond the
(...skipping 10 matching lines...) Expand all
387 corresponding performance measurement. If a list of tuples is given, 396 corresponding performance measurement. If a list of tuples is given,
388 the |units_x| argument must also be specified. 397 the |units_x| argument must also be specified.
389 units: A string representing the units of the performance measurement(s). 398 units: A string representing the units of the performance measurement(s).
390 Should not include spaces. 399 Should not include spaces.
391 graph_name: A string name for the graph associated with this performance 400 graph_name: A string name for the graph associated with this performance
392 value. Only used on Chrome desktop. 401 value. Only used on Chrome desktop.
393 units_x: A string representing the units of the x-axis values associated 402 units_x: A string representing the units of the x-axis values associated
394 with the performance measurements, such as 'iteration' if the x values 403 with the performance measurements, such as 'iteration' if the x values
395 are iteration numbers. If this argument is specified, then the 404 are iteration numbers. If this argument is specified, then the
396 |value| argument must be a list of (x, y) tuples. 405 |value| argument must be a list of (x, y) tuples.
406 is_stacked: True to draw a "stacked" graph. First-come values are
407 stacked at bottom by default.
397 """ 408 """
398 if (isinstance(value, list) and value[0] is not None and 409 if (isinstance(value, list) and value[0] is not None and
399 isinstance(value[0], tuple)): 410 isinstance(value[0], tuple)):
400 assert units_x 411 assert units_x
401 if units_x: 412 if units_x:
402 assert isinstance(value, list) 413 assert isinstance(value, list)
403 414
404 if self.IsChromeOS(): 415 if self.IsChromeOS():
405 # ChromeOS results don't support lists. 416 # ChromeOS results don't support lists.
406 if (isinstance(value, list) and value[0] is not None and 417 if (isinstance(value, list) and value[0] is not None and
(...skipping 19 matching lines...) Expand all
426 sys.stdout.flush() 437 sys.stdout.flush()
427 else: 438 else:
428 if units_x: 439 if units_x:
429 pyauto_utils.PrintPerfResult(graph_name, description, value, 440 pyauto_utils.PrintPerfResult(graph_name, description, value,
430 units + ' ' + units_x) 441 units + ' ' + units_x)
431 else: 442 else:
432 pyauto_utils.PrintPerfResult(graph_name, description, value, units) 443 pyauto_utils.PrintPerfResult(graph_name, description, value, units)
433 444
434 if self._local_perf_dir: 445 if self._local_perf_dir:
435 self._OutputPerfForStandaloneGraphing( 446 self._OutputPerfForStandaloneGraphing(
436 graph_name, description, value, units, units_x) 447 graph_name, description, value, units, units_x, is_stacked)
437 448
438 def _OutputEventForStandaloneGraphing(self, description, event_list): 449 def _OutputEventForStandaloneGraphing(self, description, event_list):
439 """Outputs event information to a local folder to be graphed. 450 """Outputs event information to a local folder to be graphed.
440 451
441 See function _OutputEventGraphValue below for a description of an event. 452 See function _OutputEventGraphValue below for a description of an event.
442 453
443 This function only applies to Chrome Endure tests running on Chrome desktop, 454 This function only applies to Chrome Endure tests running on Chrome desktop,
444 and assumes that environment variable 'LOCAL_PERF_DIR' has been specified 455 and assumes that environment variable 'LOCAL_PERF_DIR' has been specified
445 and refers to a valid directory on the local machine. 456 and refers to a valid directory on the local machine.
446 457
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2653 """Identifies the port number to which the server is currently bound. 2664 """Identifies the port number to which the server is currently bound.
2654 2665
2655 Returns: 2666 Returns:
2656 The numeric port number to which the server is currently bound. 2667 The numeric port number to which the server is currently bound.
2657 """ 2668 """
2658 return self._server.server_address[1] 2669 return self._server.server_address[1]
2659 2670
2660 2671
2661 if __name__ == '__main__': 2672 if __name__ == '__main__':
2662 pyauto_functional.Main() 2673 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/perf_endure.py » ('j') | chrome/test/functional/perf_endure.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698