| 366 | |
| 367 | |
| 368 | def read_stats(path, domain, args): |
| 369 | groups = []; |
| 370 | if args.aggregate: |
| 371 | groups = [ |
| 372 | ('Group-IC', re.compile(r".*IC_.*")), |
| 373 | ('Group-OptimizeMaglevBackground', |
| 374 | re.compile(r".*Optimize(Background|Concurrent).*Maglev.*")), |
| 375 | ('Group-OptimizeMaglev', re.compile(r".*Maglev.*")), |
| 376 | ('Group-OptimizeBackground', |
| 377 | re.compile(r".*Optimize(Background|Concurrent).*")), |
| 378 | ('Group-Optimize', |
| 379 | re.compile(r"StackGuard|.*Optimize.*|.*Deoptimize.*|Recompile.*")), |
| 380 | ('Group-CompileBackground', re.compile(r"(.*CompileBackground.*)")), |
| 381 | ('Group-Compile', re.compile(r"(^Compile.*)|(.*_Compile.*)")), |
| 382 | ('Group-ParseBackground', re.compile(r".*ParseBackground.*")), |
| 383 | ('Group-Parse', re.compile(r".*Parse.*")), |
| 384 | ('Group-Callback', re.compile(r".*Callback.*")), |
| 385 | ('Group-API', re.compile(r".*API.*")), |
| 386 | ('Group-GC-Custom', re.compile(r"GC_Custom_.*")), |
| 387 | ('Group-GC-Background', re.compile(r"GC_.*BACKGROUND.*")), |
| 388 | ('Group-GC', re.compile(r"GC_.*|AllocateInTargetSpace")), |
| 389 | ('Group-JavaScript', re.compile(r"JS_Execution")), |
| 390 | ('Group-Runtime', re.compile(r".*")) |
| 391 | ] |
| 392 | with open(path, "rt") as f: |
| 393 | # Process the whole file and sum repeating entries. |
| 394 | entries = { 'Sum': {'time': 0, 'count': 0} } |
| 395 | for group_name, regexp in groups: |
| 396 | entries[group_name] = { 'time': 0, 'count': 0 } |
| 397 | for line in f: |
| 398 | line = line.strip() |
| 399 | # Discard headers and footers. |
| 400 | if not line: continue |
| 401 | if line.startswith("Runtime Function"): continue |
| 402 | if line.startswith("===="): continue |
| 403 | if line.startswith("----"): continue |
| 404 | if line.startswith("URL:"): continue |
| 405 | if line.startswith("STATS:"): continue |
| 406 | # We have a regular line. |
| 407 | fields = line.split() |
| 408 | key = fields[0] |
| 409 | time = float(fields[1].replace("ms", "")) |
| 410 | count = int(fields[3]) |
| 411 | if key not in entries: entries[key] = { 'time': 0, 'count': 0 } |
| 412 | entries[key]['time'] += time |
| 413 | entries[key]['count'] += count |
| 414 | # We calculate the sum, if it's not the "total" line. |
| 415 | if key != "Total": |
| 416 | entries['Sum']['time'] += time |
| 417 | entries['Sum']['count'] += count |
| 418 | for group_name, regexp in groups: |
| 419 | if not regexp.match(key): continue |
| 420 | entries[group_name]['time'] += time |
| 421 | entries[group_name]['count'] += count |
| 422 | break |
| 423 | # Calculate the V8-Total (all groups except Callback) |
| 424 | group_data = { 'time': 0, 'count': 0 } |
| 425 | for group_name, regexp in groups: |