@@ -66,23 +66,24 @@ fn run_single_benchmark(bench: &BenchmarkConfig) {
6666}
6767
6868/// Collects benchmark results from criterion output and saves them to the output directory.
69- fn save_benchmark_results ( _bench : & BenchmarkConfig , output_dir : & str ) {
69+ fn save_benchmark_results ( bench : & BenchmarkConfig , output_dir : & str ) {
7070 let criterion_base = PathBuf :: from ( "target/criterion" ) ;
71- let Ok ( entries) = fs:: read_dir ( & criterion_base) else { return } ;
7271
73- // Collect all estimates files.
74- for entry in entries. flatten ( ) {
75- let path = entry. path ( ) ;
76- if !path. is_dir ( ) {
77- continue ;
78- }
72+ // Get the list of criterion benchmark names to save.
73+ // If None, use the benchmark config name.
74+ let benchmark_names: Vec < & str > = match bench. criterion_benchmark_names {
75+ Some ( names) => names. to_vec ( ) ,
76+ None => vec ! [ bench. name] ,
77+ } ;
78+
79+ // Save results for each criterion benchmark name.
80+ for bench_name in benchmark_names {
81+ let bench_path = criterion_base. join ( bench_name) ;
82+ let estimates_path = bench_path. join ( "new/estimates.json" ) ;
7983
80- // Save estimates file.
81- let estimates_path = path. join ( "new/estimates.json" ) ;
8284 if let Ok ( data) = fs:: read_to_string ( & estimates_path) {
8385 if let Ok ( json) = serde_json:: from_str :: < serde_json:: Value > ( & data) {
8486 if let Ok ( pretty) = serde_json:: to_string_pretty ( & json) {
85- let bench_name = path. file_name ( ) . unwrap ( ) . to_string_lossy ( ) ;
8687 let dest =
8788 PathBuf :: from ( output_dir) . join ( format ! ( "{}_estimates.json" , bench_name) ) ;
8889 if fs:: write ( & dest, pretty) . is_ok ( ) {
0 commit comments