(prefix: str, title=None)
| 791 | |
| 792 | |
| 793 | def pair_count_section(prefix: str, title=None) -> Section: |
| 794 | def calc_pair_count_table(stats: Stats) -> Rows: |
| 795 | opcode_stats = stats.get_opcode_stats(prefix) |
| 796 | pair_counts = opcode_stats.get_pair_counts() |
| 797 | total = opcode_stats.get_total_execution_count() |
| 798 | |
| 799 | cumulative = 0 |
| 800 | rows: Rows = [] |
| 801 | for (opcode_i, opcode_j), count in itertools.islice( |
| 802 | sorted(pair_counts.items(), key=itemgetter(1), reverse=True), 100 |
| 803 | ): |
| 804 | cumulative += count |
| 805 | rows.append( |
| 806 | ( |
| 807 | f"{opcode_i} {opcode_j}", |
| 808 | Count(count), |
| 809 | Ratio(count, total), |
| 810 | Ratio(cumulative, total), |
| 811 | ) |
| 812 | ) |
| 813 | return rows |
| 814 | |
| 815 | return Section( |
| 816 | "Pair counts", |
| 817 | f"Pair counts for top 100 {title if title else prefix} pairs", |
| 818 | [ |
| 819 | Table( |
| 820 | ("Pair", "Count:", "Self:", "Cumulative:"), |
| 821 | calc_pair_count_table, |
| 822 | ) |
| 823 | ], |
| 824 | comparative=False, |
| 825 | doc=""" |
| 826 | Pairs of specialized operations that deoptimize and are then followed by |
| 827 | the corresponding unspecialized instruction are not counted as pairs. |
| 828 | """, |
| 829 | ) |
| 830 | |
| 831 | |
| 832 | def pre_succ_pairs_section() -> Section: |
no test coverage detected
searching dependent graphs…