@@ -26,7 +26,9 @@ use tabled::settings::{Alignment, Border, Color, Modify};
26
26
use tokio:: runtime:: Runtime ;
27
27
28
28
use collector:: api:: next_artifact:: NextArtifact ;
29
- use collector:: artifact_stats:: { compile_and_get_stats, ArtifactWithStats , CargoProfile } ;
29
+ use collector:: artifact_stats:: {
30
+ compile_and_get_stats, ArtifactStats , ArtifactWithStats , CargoProfile ,
31
+ } ;
30
32
use collector:: codegen:: { codegen_diff, CodegenType } ;
31
33
use collector:: compile:: benchmark:: category:: Category ;
32
34
use collector:: compile:: benchmark:: codegen_backend:: CodegenBackend ;
@@ -431,12 +433,25 @@ struct BinaryStatsCompile {
431
433
codegen_backend2 : Option < CodegenBackend > ,
432
434
}
433
435
436
+ #[ derive( Debug , clap:: Args ) ]
437
+ #[ command( rename_all = "snake_case" ) ]
438
+ struct BinaryStatsLocal {
439
+ /// Binary artifact to examine.
440
+ artifact : PathBuf ,
441
+
442
+ /// Optional second artifact to compare with the first one.
443
+ artifact2 : Option < PathBuf > ,
444
+ }
445
+
434
446
#[ derive( Debug , clap:: Subcommand ) ]
435
447
#[ command( rename_all = "snake_case" ) ]
436
448
enum BinaryStatsMode {
437
449
/// Show size statistics for the selected compile benchmark(s).
438
450
/// Optionally compares sizes between two compiler toolchains, if `--rustc2` is provided.
439
451
Compile ( BinaryStatsCompile ) ,
452
+ /// Show size statistics for the selected binary artifact on disk.
453
+ /// Optionally compares sizes with a second provided artifact, if `--artifact2` is provided.
454
+ Local ( BinaryStatsLocal ) ,
440
455
}
441
456
442
457
// For each subcommand we list the mandatory arguments in the required
@@ -667,6 +682,9 @@ fn main_result() -> anyhow::Result<i32> {
667
682
BinaryStatsMode :: Compile ( args) => {
668
683
binary_stats_compile ( args, symbols, & target_triple) ?;
669
684
}
685
+ BinaryStatsMode :: Local ( args) => {
686
+ binary_stats_local ( args, symbols) ?;
687
+ }
670
688
}
671
689
672
690
Ok ( 0 )
@@ -1168,6 +1186,29 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
1168
1186
}
1169
1187
}
1170
1188
1189
+ fn binary_stats_local ( args : BinaryStatsLocal , symbols : bool ) -> anyhow:: Result < ( ) > {
1190
+ let stats = ArtifactStats :: from_path ( & args. artifact )
1191
+ . with_context ( || format ! ( "Cannot load artifact from {}" , args. artifact. display( ) ) ) ?;
1192
+ let stats2 = args
1193
+ . artifact2
1194
+ . as_ref ( )
1195
+ . map ( |path| {
1196
+ ArtifactStats :: from_path ( & path)
1197
+ . with_context ( || format ! ( "Cannot load artifact from {}" , path. display( ) ) )
1198
+ } )
1199
+ . transpose ( ) ?;
1200
+ print_binary_stats (
1201
+ "Sections" ,
1202
+ stats. sections ,
1203
+ stats2. as_ref ( ) . map ( |s| s. sections . clone ( ) ) ,
1204
+ ) ;
1205
+ if symbols {
1206
+ print_binary_stats ( "Symbols" , stats. symbols , stats2. map ( |s| s. symbols ) ) ;
1207
+ }
1208
+
1209
+ Ok ( ( ) )
1210
+ }
1211
+
1171
1212
fn binary_stats_compile (
1172
1213
args : BinaryStatsCompile ,
1173
1214
symbols : bool ,
0 commit comments