@@ -170,7 +170,15 @@ fn n_benchmarks_remaining(n: usize) -> String {
170
170
struct BenchmarkErrors ( usize ) ;
171
171
172
172
impl BenchmarkErrors {
173
- fn fail_if_error ( self ) -> anyhow:: Result < ( ) > {
173
+ fn new ( ) -> BenchmarkErrors {
174
+ BenchmarkErrors ( 0 )
175
+ }
176
+
177
+ fn incr ( & mut self ) {
178
+ self . 0 += 1 ;
179
+ }
180
+
181
+ fn fail_if_nonzero ( self ) -> anyhow:: Result < ( ) > {
174
182
if self . 0 > 0 {
175
183
anyhow:: bail!( "{} benchmarks failed" , self . 0 )
176
184
}
@@ -190,7 +198,7 @@ fn bench(
190
198
call_home : bool ,
191
199
self_profile : bool ,
192
200
) -> BenchmarkErrors {
193
- let mut errors_recorded = 0 ;
201
+ let mut errors = BenchmarkErrors :: new ( ) ;
194
202
eprintln ! ( "Benchmarking {} for triple {}" , cid, compiler. triple) ;
195
203
196
204
if call_home {
@@ -223,7 +231,7 @@ fn bench(
223
231
"Note that this behavior is likely to change in the future \
224
232
to collect and append the data instead."
225
233
) ;
226
- return BenchmarkErrors ( errors_recorded ) ;
234
+ return errors ;
227
235
}
228
236
let interned_cid = rt. block_on ( tx. conn ( ) . artifact_id ( & cid) ) ;
229
237
@@ -252,7 +260,7 @@ fn bench(
252
260
"collector error: Failed to benchmark '{}', recorded: {}" ,
253
261
benchmark. name, s
254
262
) ;
255
- errors_recorded += 1 ;
263
+ errors . incr ( ) ;
256
264
rt. block_on ( tx. conn ( ) . record_error (
257
265
interned_cid,
258
266
benchmark. name . 0 . as_str ( ) ,
@@ -282,7 +290,7 @@ fn bench(
282
290
// This ensures that we're good to go with the just updated data.
283
291
conn. maybe_create_indices ( ) . await ;
284
292
} ) ;
285
- BenchmarkErrors ( errors_recorded )
293
+ errors
286
294
}
287
295
288
296
fn get_benchmarks (
@@ -539,7 +547,7 @@ fn main_result() -> anyhow::Result<i32> {
539
547
540
548
let benchmarks = get_benchmarks ( & benchmark_dir, include, exclude) ?;
541
549
542
- bench (
550
+ let res = bench (
543
551
& mut rt,
544
552
conn,
545
553
& ArtifactId :: Artifact ( id. to_string ( ) ) ,
@@ -557,6 +565,7 @@ fn main_result() -> anyhow::Result<i32> {
557
565
/* call_home */ false ,
558
566
self_profile,
559
567
) ;
568
+ res. fail_if_nonzero ( ) ?;
560
569
Ok ( 0 )
561
570
}
562
571
@@ -591,7 +600,7 @@ fn main_result() -> anyhow::Result<i32> {
591
600
592
601
let benchmarks = get_benchmarks ( & benchmark_dir, None , None ) ?;
593
602
594
- bench (
603
+ let res = bench (
595
604
& mut rt,
596
605
conn,
597
606
& ArtifactId :: Commit ( commit) ,
@@ -606,6 +615,7 @@ fn main_result() -> anyhow::Result<i32> {
606
615
607
616
client. post ( & format ! ( "{}/perf/onpush" , site_url) ) . send ( ) ?;
608
617
618
+ res. fail_if_nonzero ( ) ?;
609
619
Ok ( 0 )
610
620
}
611
621
@@ -662,7 +672,7 @@ fn main_result() -> anyhow::Result<i32> {
662
672
let mut benchmarks = get_benchmarks ( & benchmark_dir, None , None ) ?;
663
673
benchmarks. retain ( |b| b. supports_stable ( ) ) ;
664
674
665
- bench (
675
+ let res = bench (
666
676
& mut rt,
667
677
conn,
668
678
& ArtifactId :: Artifact ( toolchain. to_string ( ) ) ,
@@ -680,6 +690,7 @@ fn main_result() -> anyhow::Result<i32> {
680
690
/* call_home */ false ,
681
691
/* self_profile */ false ,
682
692
) ;
693
+ res. fail_if_nonzero ( ) ?;
683
694
Ok ( 0 )
684
695
}
685
696
@@ -719,7 +730,7 @@ fn main_result() -> anyhow::Result<i32> {
719
730
/* call_home */ false ,
720
731
/* self_profile */ false ,
721
732
) ;
722
- res. fail_if_error ( ) ?;
733
+ res. fail_if_nonzero ( ) ?;
723
734
Ok ( 0 )
724
735
}
725
736
@@ -752,18 +763,21 @@ fn main_result() -> anyhow::Result<i32> {
752
763
753
764
eprintln ! ( "Profiling with {:?}" , profiler) ;
754
765
766
+ let mut errors = BenchmarkErrors :: new ( ) ;
755
767
for ( i, benchmark) in benchmarks. iter ( ) . enumerate ( ) {
756
768
eprintln ! ( "{}" , n_benchmarks_remaining( benchmarks. len( ) - i) ) ;
757
769
let mut processor = execute:: ProfileProcessor :: new ( profiler, & out_dir, & id) ;
758
770
let result =
759
771
benchmark. measure ( & mut processor, & build_kinds, & run_kinds, compiler, 1 ) ;
760
772
if let Err ( ref s) = result {
773
+ errors. incr ( ) ;
761
774
eprintln ! (
762
775
"collector error: Failed to profile '{}' with {:?}, recorded: {:?}" ,
763
776
benchmark. name, profiler, s
764
777
) ;
765
778
}
766
779
}
780
+ errors. fail_if_nonzero ( ) ?;
767
781
Ok ( 0 )
768
782
}
769
783
0 commit comments