| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 the V8 project authors. All rights reserved. | 2 # Copyright 2016 the V8 project 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 Usage: callstats.py [-h] <command> ... | 6 Usage: callstats.py [-h] <command> ... |
| 7 | 7 |
| 8 Optional arguments: | 8 Optional arguments: |
| 9 -h, --help show this help message and exit | 9 -h, --help show this help message and exit |
| 10 | 10 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 | 341 |
| 342 def read_stats(path, domain, args): | 342 def read_stats(path, domain, args): |
| 343 groups = []; | 343 groups = []; |
| 344 if args.aggregate: | 344 if args.aggregate: |
| 345 groups = [ | 345 groups = [ |
| 346 ('Group-IC', re.compile(".*IC.*")), | 346 ('Group-IC', re.compile(".*IC.*")), |
| 347 ('Group-Optimize', | 347 ('Group-Optimize', |
| 348 re.compile("StackGuard|.*Optimize.*|.*Deoptimize.*|Recompile.*")), | 348 re.compile("StackGuard|.*Optimize.*|.*Deoptimize.*|Recompile.*")), |
| 349 ('Group-Compile', re.compile(".*Compile.*")), | 349 ('Group-Compile', re.compile(".*Compile.*")), |
| 350 ('Group-ParseBackground', re.compile(".*ParseBackground.*")), |
| 350 ('Group-Parse', re.compile(".*Parse.*")), | 351 ('Group-Parse', re.compile(".*Parse.*")), |
| 351 ('Group-Callback', re.compile(".*Callback.*")), | 352 ('Group-Callback', re.compile(".*Callback.*")), |
| 352 ('Group-API', re.compile(".*API.*")), | 353 ('Group-API', re.compile(".*API.*")), |
| 353 ('Group-GC', re.compile("GC|AllocateInTargetSpace")), | 354 ('Group-GC', re.compile("GC|AllocateInTargetSpace")), |
| 354 ('Group-JavaScript', re.compile("JS_Execution")), | 355 ('Group-JavaScript', re.compile("JS_Execution")), |
| 355 ('Group-Runtime', re.compile(".*"))] | 356 ('Group-Runtime', re.compile(".*"))] |
| 356 with open(path, "rt") as f: | 357 with open(path, "rt") as f: |
| 357 # Process the whole file and sum repeating entries. | 358 # Process the whole file and sum repeating entries. |
| 358 entries = { 'Sum': {'time': 0, 'count': 0} } | 359 entries = { 'Sum': {'time': 0, 'count': 0} } |
| 359 for group_name, regexp in groups: | 360 for group_name, regexp in groups: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 378 # We calculate the sum, if it's not the "total" line. | 379 # We calculate the sum, if it's not the "total" line. |
| 379 if key != "Total": | 380 if key != "Total": |
| 380 entries['Sum']['time'] += time | 381 entries['Sum']['time'] += time |
| 381 entries['Sum']['count'] += count | 382 entries['Sum']['count'] += count |
| 382 for group_name, regexp in groups: | 383 for group_name, regexp in groups: |
| 383 if not regexp.match(key): continue | 384 if not regexp.match(key): continue |
| 384 entries[group_name]['time'] += time | 385 entries[group_name]['time'] += time |
| 385 entries[group_name]['count'] += count | 386 entries[group_name]['count'] += count |
| 386 break | 387 break |
| 387 # Calculate the V8-Total (all groups except Callback) | 388 # Calculate the V8-Total (all groups except Callback) |
| 388 total_v8 = { 'time': 0, 'count': 0 } | 389 group_data = { 'time': 0, 'count': 0 } |
| 389 for group_name, regexp in groups: | 390 for group_name, regexp in groups: |
| 390 if group_name == 'Group-Callback': continue | 391 if group_name == 'Group-Callback': continue |
| 391 total_v8['time'] += entries[group_name]['time'] | 392 group_data['time'] += entries[group_name]['time'] |
| 392 total_v8['count'] += entries[group_name]['count'] | 393 group_data['count'] += entries[group_name]['count'] |
| 393 entries['Group-Total-V8'] = total_v8 | 394 entries['Group-Total-V8'] = group_data |
| 395 # Calculate the Parse-Total group |
| 396 group_data = { 'time': 0, 'count': 0 } |
| 397 for group_name, regexp in groups: |
| 398 if !group_name.startswith('Group-Parse'): continue |
| 399 group_data['time'] += entries[group_name]['time'] |
| 400 group_data['count'] += entries[group_name]['count'] |
| 401 entries['Group-Parse-Total'] = group_data |
| 394 # Append the sums as single entries to domain. | 402 # Append the sums as single entries to domain. |
| 395 for key in entries: | 403 for key in entries: |
| 396 if key not in domain: domain[key] = { 'time_list': [], 'count_list': [] } | 404 if key not in domain: domain[key] = { 'time_list': [], 'count_list': [] } |
| 397 domain[key]['time_list'].append(entries[key]['time']) | 405 domain[key]['time_list'].append(entries[key]['time']) |
| 398 domain[key]['count_list'].append(entries[key]['count']) | 406 domain[key]['count_list'].append(entries[key]['count']) |
| 399 | 407 |
| 400 | 408 |
| 401 def print_stats(S, args): | 409 def print_stats(S, args): |
| 402 # Sort by ascending/descending time average, then by ascending/descending | 410 # Sort by ascending/descending time average, then by ascending/descending |
| 403 # count average, then by ascending name. | 411 # count average, then by ascending name. |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 args.error("use either option --sites-file or site URLs") | 688 args.error("use either option --sites-file or site URLs") |
| 681 sys.exit(1) | 689 sys.exit(1) |
| 682 elif args.command == "run" and not coexist(args.replay_wpr, args.replay_bin): | 690 elif args.command == "run" and not coexist(args.replay_wpr, args.replay_bin): |
| 683 args.error("options --replay-wpr and --replay-bin must be used together") | 691 args.error("options --replay-wpr and --replay-bin must be used together") |
| 684 sys.exit(1) | 692 sys.exit(1) |
| 685 else: | 693 else: |
| 686 args.func(args) | 694 args.func(args) |
| 687 | 695 |
| 688 if __name__ == "__main__": | 696 if __name__ == "__main__": |
| 689 sys.exit(main()) | 697 sys.exit(main()) |
| OLD | NEW |