@@ -6,11 +6,7 @@ use crate::{
6
6
} ;
7
7
use anyhow:: Context ;
8
8
use cargo_metadata:: { Metadata , Package } ;
9
- use codspeed:: {
10
- walltime:: get_raw_result_dir_from_workspace_root,
11
- walltime_results:: { WalltimeBenchmark , WalltimeResults } ,
12
- } ;
13
- use glob:: glob;
9
+ use codspeed:: walltime_results:: WalltimeResults ;
14
10
use std:: {
15
11
io:: { self , Write } ,
16
12
os:: unix:: process:: ExitStatusExt ,
@@ -105,7 +101,7 @@ pub fn run_benches(
105
101
let codspeed_target_dir = get_codspeed_target_dir ( metadata, measurement_mode) ;
106
102
let workspace_root = metadata. workspace_root . as_std_path ( ) ;
107
103
if measurement_mode == MeasurementMode :: Walltime {
108
- clear_raw_walltime_data ( workspace_root) ?;
104
+ WalltimeResults :: clear ( workspace_root) ?;
109
105
}
110
106
let benches = filters. benches_to_run ( codspeed_target_dir, metadata) ?;
111
107
if benches. is_empty ( ) {
@@ -183,35 +179,14 @@ pub fn run_benches(
183
179
Ok ( ( ) )
184
180
}
185
181
186
- fn clear_raw_walltime_data ( workspace_root : & Path ) -> Result < ( ) > {
187
- let raw_results_dir = get_raw_result_dir_from_workspace_root ( workspace_root) ;
188
- std:: fs:: remove_dir_all ( & raw_results_dir) . ok ( ) ; // ignore errors when the directory does not exist
189
- std:: fs:: create_dir_all ( & raw_results_dir) . context ( "Failed to create raw_results directory" ) ?;
190
- Ok ( ( ) )
191
- }
192
-
193
182
fn aggregate_raw_walltime_data ( workspace_root : & Path ) -> Result < ( ) > {
194
- // retrieve data from `{workspace_root}/target/codspeed/raw_results/{scope}/*.json
195
- let walltime_benchmarks = glob ( & format ! (
196
- "{}/**/*.json" ,
197
- get_raw_result_dir_from_workspace_root( workspace_root)
198
- . to_str( )
199
- . unwrap( ) ,
200
- ) ) ?
201
- . map ( |sample| {
202
- let sample = sample?;
203
- let raw_walltime_data: codspeed:: walltime:: RawWallTimeData =
204
- serde_json:: from_reader ( std:: fs:: File :: open ( & sample) ?) ?;
205
- Ok ( WalltimeBenchmark :: from ( raw_walltime_data) )
206
- } )
207
- . collect :: < Result < Vec < _ > > > ( ) ?;
208
-
209
- if walltime_benchmarks. is_empty ( ) {
183
+ let results = WalltimeResults :: collect_walltime_results ( workspace_root) ?;
184
+ if results. benchmarks ( ) . is_empty ( ) {
210
185
eprintln ! ( "No walltime benchmarks found" ) ;
211
186
return Ok ( ( ) ) ;
212
187
}
213
188
214
- for bench in & walltime_benchmarks {
189
+ for bench in results . benchmarks ( ) {
215
190
if bench. is_invalid ( ) {
216
191
eprintln ! (
217
192
"Warning: Benchmark {} was possibly optimized away" ,
@@ -226,7 +201,6 @@ fn aggregate_raw_walltime_data(workspace_root: &Path) -> Result<()> {
226
201
. join ( "results" ) ;
227
202
std:: fs:: create_dir_all ( & results_folder) . context ( "Failed to create results folder" ) ?;
228
203
229
- let results = WalltimeResults :: from_benchmarks ( walltime_benchmarks) ;
230
204
let results_path = results_folder. join ( format ! ( "{}.json" , std:: process:: id( ) ) ) ;
231
205
let mut results_file =
232
206
std:: fs:: File :: create ( & results_path) . context ( "Failed to create results file" ) ?;
0 commit comments