@@ -7,6 +7,7 @@ use crate::load::SiteCtxt;
7
7
use database:: { ArtifactId , QueuedCommit } ;
8
8
9
9
use crate :: github:: { COMMENT_MARK_ROLLUP , COMMENT_MARK_TEMPORARY , RUST_REPO_GITHUB_API_URL } ;
10
+ use humansize:: BINARY ;
10
11
use std:: collections:: HashSet ;
11
12
use std:: fmt:: Write ;
12
13
@@ -228,6 +229,7 @@ async fn summarize_run(
228
229
}
229
230
230
231
let bootstrap = summarize_bootstrap ( & inst_comparison) ;
232
+ let artifact_size = summarize_artifact_size ( & inst_comparison) ;
231
233
232
234
let metrics = vec ! [
233
235
(
@@ -267,10 +269,28 @@ async fn summarize_run(
267
269
}
268
270
269
271
write ! ( & mut message, "\n {bootstrap}" ) . unwrap ( ) ;
272
+ write ! ( & mut message, "\n {artifact_size}" ) . unwrap ( ) ;
270
273
271
274
Ok ( message)
272
275
}
273
276
277
+ fn summarize_artifact_size ( comparison : & ArtifactComparison ) -> String {
278
+ let size_prev = comparison. a . component_sizes . values ( ) . sum :: < u64 > ( ) ;
279
+ let size_current = comparison. b . component_sizes . values ( ) . sum :: < u64 > ( ) ;
280
+ if size_prev == 0 || size_current == 0 {
281
+ return "**Artifact size**: missing data" . to_string ( ) ;
282
+ }
283
+
284
+ let change = ( size_current as f64 / size_prev as f64 ) - 1.0 ;
285
+ let change = change * 100.0 ;
286
+
287
+ format ! (
288
+ "**Artifact size**: {} -> {} ({change:.2}%)" ,
289
+ humansize:: format_size( size_prev, BINARY ) ,
290
+ humansize:: format_size( size_current, BINARY )
291
+ )
292
+ }
293
+
274
294
fn summarize_bootstrap ( comparison : & ArtifactComparison ) -> String {
275
295
let prev_s = comparison. a . bootstrap_total as f64 / 1e9 ;
276
296
let current_s = comparison. b . bootstrap_total as f64 / 1e9 ;
0 commit comments