@@ -18,9 +18,10 @@ use crate::diff::{DifferenceReport, ReportItemDifference};
18
18
pub struct DiffSummary {
19
19
pub unit_name : String ,
20
20
pub name : String ,
21
+ pub fuzzy_percent : f32 ,
21
22
pub percent_difference : f32 ,
22
23
pub size : u64 ,
23
- pub size_difference : u64 ,
24
+ pub size_difference : i64 ,
24
25
}
25
26
26
27
// test
@@ -34,31 +35,33 @@ impl DiffSummary {
34
35
None => diff. name . clone ( ) ,
35
36
} ,
36
37
size : diff. size ,
38
+ fuzzy_percent : diff. new_fuzzy_match_percent ,
37
39
percent_difference : percent_diff,
38
- size_difference : ( ( ( diff. size as f32 ) * ( percent_diff / 100.0 ) ) as u64 ) ,
40
+ size_difference : ( ( ( diff. size as f32 ) * ( percent_diff / 100.0 ) ) as i64 ) ,
39
41
}
40
42
}
41
43
42
44
pub fn to_string ( & self ) -> String {
43
45
let direction = if self . percent_difference > 0.0 {
44
46
"+"
45
47
} else {
46
- "-"
48
+ "" // Don't need to add the minus sign, Rust will do it on its own
47
49
} ;
50
+
48
51
//println!("{:?}", self);
49
- let percent = format ! ( "{:.2}%" , self . percent_difference ) ;
52
+ let percent = format ! ( "{:.2}%" , self . fuzzy_percent ) ;
50
53
51
- let emoji = match self . percent_difference {
54
+ let emoji = match self . fuzzy_percent {
52
55
100.00 => "✅" ,
53
56
_ => match self . percent_difference > 0.0 {
54
57
true => "📈" ,
55
- false => "📉 " ,
58
+ false => "⚠️ " ,
56
59
} ,
57
60
} ;
58
61
59
62
format ! (
60
- "{emoji} `{}` - ` {}`: {direction}{} ({direction}{}) " ,
61
- self . unit_name, self . name, percent , self . size_difference
63
+ "{emoji} `{} - {}` {direction}{} bytes -> {percent} " ,
64
+ self . unit_name, self . name, self . size_difference
62
65
)
63
66
}
64
67
}
@@ -90,17 +93,22 @@ impl PullRequestReport {
90
93
. iter ( )
91
94
. filter ( |i| i. new_fuzzy_match_percent < i. old_fuzzy_match_percent )
92
95
. map ( |i| Regression ( DiffSummary :: new ( i) ) )
96
+ . filter ( |x| x. 0 . size_difference != 0 )
93
97
. collect ( )
94
98
}
95
99
96
100
pub fn get_progressions ( & self ) -> Vec < Progression > {
97
101
let mut items: Vec < ReportItemDifference > = self . diffs . sections . clone ( ) ;
98
- items. extend ( self . diffs . functions . clone ( ) ) ;
102
+ items. sort_by_key ( |x| x. size as i32 * -1 ) ;
103
+ let mut fns = self . diffs . functions . clone ( ) ;
104
+ fns. sort_by_key ( |x| x. size as i32 * -1 ) ;
105
+ items. extend ( fns) ;
99
106
100
107
items
101
108
. iter ( )
102
109
. filter ( |i| i. new_fuzzy_match_percent > i. old_fuzzy_match_percent )
103
110
. map ( |i| Progression ( DiffSummary :: new ( i) ) )
111
+ . filter ( |x| x. 0 . size_difference != 0 )
104
112
. collect ( )
105
113
}
106
114
@@ -122,6 +130,7 @@ impl PullRequestReport {
122
130
false => "No Regressions 🎉" . to_owned ( ) ,
123
131
true => format ! ( "Regressions: {regression_count}" ) ,
124
132
} ;
133
+
125
134
let regressions_string = match regressions_exist {
126
135
false => "" . to_owned ( ) ,
127
136
true => {
@@ -144,9 +153,29 @@ impl PullRequestReport {
144
153
}
145
154
} ;
146
155
156
+ let size_diff = progressions
157
+ . iter ( )
158
+ . map ( |x| x. 0 . size_difference )
159
+ . sum :: < i64 > ( ) ;
160
+ let size_direction = if size_diff >= 0 { "+" } else { "" } ;
161
+
162
+ let ok_rating = match size_diff {
163
+ diff if diff >= 5_000 => "You are a decomp GOD, can I have your autograph?" ,
164
+ diff if diff >= 2_000 => "Amazing contribution, you are the decomp GOAT 🐐" ,
165
+ diff if diff >= 1_000 => "A Fantastic contribution! ✨🎉" ,
166
+ diff if diff > 750 => "Ay, dios mio, gracias por la contribución!" ,
167
+ diff if diff > 500 => "A solid contribution, Спасибо!" ,
168
+ diff if diff > 250 => "A decent contribution. Thank you!" ,
169
+ diff if diff < 100 => "A small but commendable contribution" ,
170
+ diff if diff < 0 => "You're going in the wrong direction..?" ,
171
+ diff if diff < -1_000 => "You really screwed up 🙉" ,
172
+ _ => "I don't have an opinion" ,
173
+ } ;
174
+
147
175
let lines: Vec < String > = vec ! [
148
- // h
149
176
format!( "# {}" , header) ,
177
+ format!( "{}{} bytes" , size_direction, size_diff) ,
178
+ format!( "🆗 Bot Rating: {}" , ok_rating) ,
150
179
format!( "## {}" , regressions_header) ,
151
180
regressions_string,
152
181
format!( "## {}" , progress_header) ,
0 commit comments