@@ -18,9 +18,10 @@ use crate::diff::{DifferenceReport, ReportItemDifference};
1818pub struct DiffSummary {
1919 pub unit_name : String ,
2020 pub name : String ,
21+ pub fuzzy_percent : f32 ,
2122 pub percent_difference : f32 ,
2223 pub size : u64 ,
23- pub size_difference : u64 ,
24+ pub size_difference : i64 ,
2425}
2526
2627// test
@@ -34,31 +35,33 @@ impl DiffSummary {
3435 None => diff. name . clone ( ) ,
3536 } ,
3637 size : diff. size ,
38+ fuzzy_percent : diff. new_fuzzy_match_percent ,
3739 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 ) ,
3941 }
4042 }
4143
4244 pub fn to_string ( & self ) -> String {
4345 let direction = if self . percent_difference > 0.0 {
4446 "+"
4547 } else {
46- "-"
48+ "" // Don't need to add the minus sign, Rust will do it on its own
4749 } ;
50+
4851 //println!("{:?}", self);
49- let percent = format ! ( "{:.2}%" , self . percent_difference ) ;
52+ let percent = format ! ( "{:.2}%" , self . fuzzy_percent ) ;
5053
51- let emoji = match self . percent_difference {
54+ let emoji = match self . fuzzy_percent {
5255 100.00 => "✅" ,
5356 _ => match self . percent_difference > 0.0 {
5457 true => "📈" ,
55- false => "📉 " ,
58+ false => "⚠️ " ,
5659 } ,
5760 } ;
5861
5962 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
6265 )
6366 }
6467}
@@ -90,17 +93,22 @@ impl PullRequestReport {
9093 . iter ( )
9194 . filter ( |i| i. new_fuzzy_match_percent < i. old_fuzzy_match_percent )
9295 . map ( |i| Regression ( DiffSummary :: new ( i) ) )
96+ . filter ( |x| x. 0 . size_difference != 0 )
9397 . collect ( )
9498 }
9599
96100 pub fn get_progressions ( & self ) -> Vec < Progression > {
97101 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) ;
99106
100107 items
101108 . iter ( )
102109 . filter ( |i| i. new_fuzzy_match_percent > i. old_fuzzy_match_percent )
103110 . map ( |i| Progression ( DiffSummary :: new ( i) ) )
111+ . filter ( |x| x. 0 . size_difference != 0 )
104112 . collect ( )
105113 }
106114
@@ -122,6 +130,7 @@ impl PullRequestReport {
122130 false => "No Regressions 🎉" . to_owned ( ) ,
123131 true => format ! ( "Regressions: {regression_count}" ) ,
124132 } ;
133+
125134 let regressions_string = match regressions_exist {
126135 false => "" . to_owned ( ) ,
127136 true => {
@@ -144,9 +153,29 @@ impl PullRequestReport {
144153 }
145154 } ;
146155
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+
147175 let lines: Vec < String > = vec ! [
148- // h
149176 format!( "# {}" , header) ,
177+ format!( "{}{} bytes" , size_direction, size_diff) ,
178+ format!( "🆗 Bot Rating: {}" , ok_rating) ,
150179 format!( "## {}" , regressions_header) ,
151180 regressions_string,
152181 format!( "## {}" , progress_header) ,
0 commit comments