()
| 419 | |
| 420 | |
| 421 | def main(): |
| 422 | args = parse_args() |
| 423 | story = args.story[0] |
| 424 | |
| 425 | retain = args.retain |
| 426 | if args.dir is not None: |
| 427 | output_dir = args.dir |
| 428 | if not os.path.isdir(output_dir): |
| 429 | print("Specified output directory does not exist: " % output_dir) |
| 430 | sys.exit(1) |
| 431 | else: |
| 432 | output_dir = tempfile.mkdtemp(prefix="runtime_call_stats_") |
| 433 | run_benchmark( |
| 434 | story, |
| 435 | repeats=args.repeats, |
| 436 | output_dir=output_dir, |
| 437 | verbose=args.verbose, |
| 438 | js_flags=args.js_flags, |
| 439 | browser_args=args.browser_args, |
| 440 | chromium_dir=args.chromium_dir, |
| 441 | benchmark=args.benchmark, |
| 442 | executable=args.executable, |
| 443 | browser=args.browser, |
| 444 | device=args.device) |
| 445 | |
| 446 | try: |
| 447 | buckets = collect_buckets( |
| 448 | story, group=args.group, repeats=args.repeats, output_dir=output_dir) |
| 449 | |
| 450 | for b in buckets.values(): |
| 451 | b.prepare(args.stdev) |
| 452 | |
| 453 | table = create_table( |
| 454 | buckets, record_bucket_names=args.group, filter=args.filter) |
| 455 | |
| 456 | headers = [""] + ["Count", "Duration\n(ms)"] * args.repeats |
| 457 | if args.repeats > 1: |
| 458 | if args.stdev: |
| 459 | headers += [ |
| 460 | "Count\nMean", "Count\nStdev", "Duration\nMean (ms)", |
| 461 | "Duration\nStdev (ms)" |
| 462 | ] |
| 463 | else: |
| 464 | headers += ["Count\nMean", "Duration\nMean (ms)"] |
| 465 | |
| 466 | if args.out_file: |
| 467 | with open(args.out_file, "w", newline="") as f: |
| 468 | write_output(f, table, headers, args.repeats, args.format) |
| 469 | else: |
| 470 | write_output(sys.stdout, table, headers, args.repeats, args.format) |
| 471 | finally: |
| 472 | if retain == "none": |
| 473 | shutil.rmtree(output_dir) |
| 474 | elif retain == "json": |
| 475 | # Delete all files bottom up except ones ending in JSON_FILE_EXTENSION and |
| 476 | # attempt to delete subdirectories (ignoring errors). |
| 477 | for dir_name, subdir_list, file_list in os.walk( |
| 478 | output_dir, topdown=False): |
no test coverage detected