@@ -1954,7 +1954,7 @@ def aggregate_diff_metrics(details_file):
1954
1954
# Project out these fields for the saved diffs, to use for further
1955
1955
# processing. Saving everything into memory is costly on memory when there
1956
1956
# are a large number of diffs.
1957
- diffs_fields = ["Context" , "Context size" , "Base ActualCodeBytes" , "Diff ActualCodeBytes" , "Base PerfScore" , "Diff PerfScore" ]
1957
+ diffs_fields = ["Context" , "Method full name" , " Context size" , "Base ActualCodeBytes" , "Diff ActualCodeBytes" , "Base PerfScore" , "Diff PerfScore" ]
1958
1958
diffs = []
1959
1959
1960
1960
for row in read_csv (details_file ):
@@ -2725,12 +2725,22 @@ def diff_pct(r):
2725
2725
2726
2726
display_subset ("Smallest {} zero sized diffs:" , smallest_zero_size_contexts )
2727
2727
2728
- by_diff_size_pct_examples = [diff for diff in by_diff_size_pct if abs (int (diff ['Diff ActualCodeBytes' ]) - int (diff ['Base ActualCodeBytes' ])) < 50 ]
2729
- if len (by_diff_size_pct_examples ) == 0 :
2730
- by_diff_size_pct_examples = by_diff_size_pct
2728
+ # Prefer to show small diffs over large percentage wise diffs; sort by this additionally.
2729
+ # sorted is stable, so for multiple small diffs this will keep them in order of percentage wise improvement/regression.
2730
+ def is_small_diff (row ):
2731
+ if abs (int (row ['Diff ActualCodeBytes' ]) - int (row ['Base ActualCodeBytes' ])) < 50 :
2732
+ return 0
2733
+
2734
+ return 1
2735
+
2736
+ by_small_then_improvement = sorted (by_diff_size_pct , key = is_small_diff )
2737
+ by_small_then_regression = sorted (reversed (by_diff_size_pct ), key = is_small_diff )
2738
+
2739
+ example_improvements = by_small_then_improvement [:3 ]
2740
+
2741
+ example_improvement_contexts = set (row ["Context" ] for row in example_improvements )
2742
+ example_regressions = [row for row in by_small_then_regression if row ["Context" ] not in example_improvement_contexts ][:3 ]
2731
2743
2732
- example_improvements = by_diff_size_pct_examples [:3 ]
2733
- example_regressions = by_diff_size_pct_examples [3 :][- 3 :]
2734
2744
contexts = smallest_contexts + top_improvements + top_regressions + top_improvements_pct + top_regressions_pct + smallest_zero_size_contexts + example_improvements + example_regressions
2735
2745
examples = example_improvements + example_regressions
2736
2746
0 commit comments