@@ -55,22 +55,11 @@ fn main() -> Result<(), Box<dyn Error>> {
55
55
let manifest: toml:: Value = toml:: from_str ( & manifest_contents) ?;
56
56
57
57
let table = manifest. as_table ( ) . unwrap ( ) ;
58
- let profile = table. get ( "profile" ) ;
59
- let release = profile
60
- . and_then ( |p| p. as_table ( ) )
61
- . and_then ( |t| t. get ( "release" ) )
62
- . and_then ( |t| t. as_table ( ) ) ;
63
- let debug = release. and_then ( |t| t. get ( "debug" ) ) ;
64
- let lto = release. and_then ( |t| t. get ( "lto" ) ) ;
65
- let codegen_units = release. and_then ( |t| t. get ( "codegen-units" ) ) ;
66
-
58
+ let profiles = table. get ( "profile" ) ;
67
59
let metadata = CompileBenchmarkMetadata {
68
60
perf_config : config,
69
- release_metadata : ProfileMetadata {
70
- debug : debug. map ( |v| v. to_string ( ) ) ,
71
- lto : lto. map ( |v| v. to_string ( ) ) ,
72
- codegen_units : codegen_units. and_then ( |v| v. as_integer ( ) . map ( |v| v as u32 ) ) ,
73
- } ,
61
+ release_metadata : read_profile_metadata ( profiles, "release" ) ,
62
+ dev_metadata : read_profile_metadata ( profiles, "dev" ) ,
74
63
} ;
75
64
suite. insert ( benchmark_name, metadata) ;
76
65
}
@@ -82,3 +71,23 @@ fn main() -> Result<(), Box<dyn Error>> {
82
71
83
72
Ok ( ( ) )
84
73
}
74
+
75
+ /// If the manifest has `profile.*` entries, read some of the compilation metadata from a built-in
76
+ /// profile with the given `profile` name, if it exists (for example, the options for cargo's
77
+ /// optimized profile is named `release`).
78
+ /// Note that some, or all, of the metadata that we want to display may be missing from the
79
+ /// manifest: it just won't be shown in the UI in that case.
80
+ fn read_profile_metadata ( profiles : Option < & toml:: Value > , profile : & str ) -> ProfileMetadata {
81
+ let profile = profiles
82
+ . and_then ( |p| p. as_table ( ) )
83
+ . and_then ( |t| t. get ( profile) )
84
+ . and_then ( |t| t. as_table ( ) ) ;
85
+ let debug = profile. and_then ( |t| t. get ( "debug" ) ) ;
86
+ let lto = profile. and_then ( |t| t. get ( "lto" ) ) ;
87
+ let codegen_units = profile. and_then ( |t| t. get ( "codegen-units" ) ) ;
88
+ ProfileMetadata {
89
+ debug : debug. map ( |v| v. to_string ( ) ) ,
90
+ lto : lto. map ( |v| v. to_string ( ) ) ,
91
+ codegen_units : codegen_units. and_then ( |v| v. as_integer ( ) . map ( |v| v as u32 ) ) ,
92
+ }
93
+ }
0 commit comments