| 527 | |
| 528 | # Create a Total page with all entries summed up. |
| 529 | def create_total_page_stats(domains, args): |
| 530 | total = {} |
| 531 | def sum_up(parent, key, other): |
| 532 | sums = parent[key] |
| 533 | for i, item in enumerate(other[key]): |
| 534 | if i >= len(sums): |
| 535 | sums.extend([0] * (i - len(sums) + 1)) |
| 536 | if item is not None: |
| 537 | sums[i] += item |
| 538 | # Exclude adwords and speedometer pages from aggrigate total, since adwords |
| 539 | # dominates execution time and speedometer is measured elsewhere. |
| 540 | excluded_domains = ['adwords.google.com', 'speedometer-angular', |
| 541 | 'speedometer-jquery', 'speedometer-backbone', |
| 542 | 'speedometer-ember', 'speedometer-vanilla']; |
| 543 | # Sum up all the entries/metrics from all non-excluded domains |
| 544 | for domain, entries in domains.items(): |
| 545 | if domain in excluded_domains: |
| 546 | continue; |
| 547 | for key, domain_stats in entries.items(): |
| 548 | if key not in total: |
| 549 | total[key] = {} |
| 550 | total[key]['time_list'] = list(domain_stats['time_list']) |
| 551 | total[key]['count_list'] = list(domain_stats['count_list']) |
| 552 | else: |
| 553 | sum_up(total[key], 'time_list', domain_stats) |
| 554 | sum_up(total[key], 'count_list', domain_stats) |
| 555 | # Add a new "Total" page containing the summed up metrics. |
| 556 | domains['Total'] = total |
| 557 | |
| 558 | # Generate Raw JSON file. |
| 559 | |