()
| 984 | |
| 985 | |
| 986 | def specialization_effectiveness_section() -> Section: |
| 987 | def calc_specialization_effectiveness_table(stats: Stats) -> Rows: |
| 988 | opcode_stats = stats.get_opcode_stats("opcode") |
| 989 | total = opcode_stats.get_total_execution_count() |
| 990 | |
| 991 | ( |
| 992 | basic, |
| 993 | specialized_hits, |
| 994 | specialized_misses, |
| 995 | not_specialized, |
| 996 | ) = opcode_stats.get_specialized_total_counts() |
| 997 | |
| 998 | return [ |
| 999 | ( |
| 1000 | Doc( |
| 1001 | "Basic", |
| 1002 | "Instructions that are not and cannot be specialized, e.g. `LOAD_FAST`.", |
| 1003 | ), |
| 1004 | Count(basic), |
| 1005 | Ratio(basic, total), |
| 1006 | ), |
| 1007 | ( |
| 1008 | Doc( |
| 1009 | "Not specialized", |
| 1010 | "Instructions that could be specialized but aren't, e.g. `LOAD_ATTR`, `BINARY_SLICE`.", |
| 1011 | ), |
| 1012 | Count(not_specialized), |
| 1013 | Ratio(not_specialized, total), |
| 1014 | ), |
| 1015 | ( |
| 1016 | Doc( |
| 1017 | "Specialized hits", |
| 1018 | "Specialized instructions, e.g. `LOAD_ATTR_MODULE` that complete.", |
| 1019 | ), |
| 1020 | Count(specialized_hits), |
| 1021 | Ratio(specialized_hits, total), |
| 1022 | ), |
| 1023 | ( |
| 1024 | Doc( |
| 1025 | "Specialized misses", |
| 1026 | "Specialized instructions, e.g. `LOAD_ATTR_MODULE` that deopt.", |
| 1027 | ), |
| 1028 | Count(specialized_misses), |
| 1029 | Ratio(specialized_misses, total), |
| 1030 | ), |
| 1031 | ] |
| 1032 | |
| 1033 | def calc_deferred_by_table(stats: Stats) -> Rows: |
| 1034 | opcode_stats = stats.get_opcode_stats("opcode") |
| 1035 | deferred_counts = opcode_stats.get_deferred_counts() |
| 1036 | total = sum(deferred_counts.values()) |
| 1037 | if total == 0: |
| 1038 | return [] |
| 1039 | |
| 1040 | return [ |
| 1041 | (name, Count(value), Ratio(value, total)) |
| 1042 | for name, value in sorted( |
| 1043 | deferred_counts.items(), key=itemgetter(1), reverse=True |
no test coverage detected
searching dependent graphs…