File tree Expand file tree Collapse file tree 8 files changed +48
-19
lines changed
criterion_compat/criterion_fork/src
divan_compat/divan_fork/src Expand file tree Collapse file tree 8 files changed +48
-19
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,12 @@ use cargo_metadata::{Metadata, Package};
9
9
use codspeed:: walltime_results:: WalltimeResults ;
10
10
use std:: {
11
11
io:: { self , Write } ,
12
- os:: unix:: process:: ExitStatusExt ,
13
12
path:: { Path , PathBuf } ,
14
13
} ;
15
14
15
+ #[ cfg( unix) ]
16
+ use std:: os:: unix:: process:: ExitStatusExt ;
17
+
16
18
struct BenchToRun {
17
19
bench_path : PathBuf ,
18
20
bench_name : String ,
@@ -156,13 +158,21 @@ pub fn run_benches(
156
158
if status. success ( ) {
157
159
Ok ( ( ) )
158
160
} else {
159
- let code = status
160
- . code ( )
161
- . or ( status. signal ( ) . map ( |s| 128 + s) ) // 128+N indicates that a command was interrupted by signal N (see: https://tldp.org/LDP/abs/html/exitcodes.html)
162
- . unwrap_or ( 1 ) ;
161
+ #[ cfg( unix) ]
162
+ {
163
+ let code = status
164
+ . code ( )
165
+ . or ( status. signal ( ) . map ( |s| 128 + s) ) // 128+N indicates that a command was interrupted by signal N (see: https://tldp.org/LDP/abs/html/exitcodes.html)
166
+ . unwrap_or ( 1 ) ;
167
+
168
+ eprintln ! ( "failed to execute the benchmark process, exit code: {code}" ) ;
163
169
164
- eprintln ! ( "failed to execute the benchmark process, exit code: {code}" ) ;
165
- std:: process:: exit ( code) ;
170
+ std:: process:: exit ( code) ;
171
+ }
172
+ #[ cfg( not( unix) ) ]
173
+ {
174
+ bail ! ( "failed to execute the benchmark process: {}" , status)
175
+ }
166
176
}
167
177
} ) ?;
168
178
eprintln ! ( "Done running {bench_name}" ) ;
Original file line number Diff line number Diff line change 1
1
pub mod codspeed;
2
+
3
+ #[ cfg( unix) ]
2
4
pub mod fifo;
5
+
3
6
mod macros;
4
7
mod measurement;
5
8
mod request;
Original file line number Diff line number Diff line change 1
1
//! WARNING: Has to be in sync with `runner`.
2
2
3
+ #[ cfg( unix) ]
3
4
pub const RUNNER_CTL_FIFO : & str = "/tmp/runner.ctl.fifo" ;
5
+ #[ cfg( unix) ]
4
6
pub const RUNNER_ACK_FIFO : & str = "/tmp/runner.ack.fifo" ;
5
7
6
8
#[ derive( serde:: Serialize , serde:: Deserialize , Debug , PartialEq ) ]
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ mod tests {
71
71
assert_eq ! ( relative_path, path_dir. canonicalize( ) . unwrap( ) ) ;
72
72
}
73
73
74
+ #[ cfg( unix) ]
74
75
#[ test]
75
76
fn test_get_git_relative_path_not_found_with_symlink ( ) {
76
77
let dir = tempdir ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -297,12 +297,17 @@ mod codspeed {
297
297
) {
298
298
let ( uri, bench_name) = create_uri_and_name ( id, c) ;
299
299
300
- if let Err ( error) = :: codspeed:: fifo:: send_cmd ( codspeed:: fifo:: Command :: CurrentBenchmark {
301
- pid : std:: process:: id ( ) ,
302
- uri : uri. clone ( ) ,
303
- } ) {
304
- if codspeed:: utils:: running_with_codspeed_runner ( ) {
305
- eprintln ! ( "Failed to send benchmark URI to runner: {error:?}" ) ;
300
+ #[ cfg( unix) ]
301
+ {
302
+ if let Err ( error) =
303
+ :: codspeed:: fifo:: send_cmd ( codspeed:: fifo:: Command :: CurrentBenchmark {
304
+ pid : std:: process:: id ( ) ,
305
+ uri : uri. clone ( ) ,
306
+ } )
307
+ {
308
+ if codspeed:: utils:: running_with_codspeed_runner ( ) {
309
+ eprintln ! ( "Failed to send benchmark URI to runner: {error:?}" ) ;
310
+ }
306
311
}
307
312
}
308
313
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ pub(crate) trait Routine<M: Measurement, T: ?Sized> {
192
192
}
193
193
194
194
let m_elapsed = {
195
+ #[ cfg( unix) ]
195
196
let _guard = codspeed:: fifo:: BenchGuard :: new_with_runner_fifo ( ) ;
196
197
self . bench ( measurement, & m_iters, parameter)
197
198
} ;
Original file line number Diff line number Diff line change @@ -657,6 +657,7 @@ impl<'a> BenchContext<'a> {
657
657
658
658
let bench_overheads = timer. bench_overheads ( ) ;
659
659
660
+ #[ cfg( unix) ]
660
661
let _guard = codspeed:: fifo:: BenchGuard :: new_with_runner_fifo ( ) ;
661
662
while {
662
663
// Conditions for when sampling is over:
@@ -811,6 +812,7 @@ impl<'a> BenchContext<'a> {
811
812
elapsed_picos = elapsed_picos. saturating_add ( progress_picos) ;
812
813
}
813
814
}
815
+ #[ cfg( unix) ]
814
816
core:: mem:: drop ( _guard) ;
815
817
816
818
// Reset flag for ignoring allocations.
Original file line number Diff line number Diff line change @@ -430,12 +430,17 @@ mod codspeed {
430
430
bench_context. samples . time_samples . iter ( ) . map ( |s| s. duration . picos / 1_000 ) . collect ( ) ;
431
431
let max_time_ns = bench_context. options . max_time . map ( |t| t. as_nanos ( ) ) ;
432
432
433
- if let Err ( error) = :: codspeed:: fifo:: send_cmd ( codspeed:: fifo:: Command :: CurrentBenchmark {
434
- pid : std:: process:: id ( ) ,
435
- uri : uri. clone ( ) ,
436
- } ) {
437
- if codspeed:: utils:: running_with_codspeed_runner ( ) {
438
- eprintln ! ( "Failed to send benchmark URI to runner: {error:?}" ) ;
433
+ #[ cfg( unix) ]
434
+ {
435
+ if let Err ( error) =
436
+ :: codspeed:: fifo:: send_cmd ( codspeed:: fifo:: Command :: CurrentBenchmark {
437
+ pid : std:: process:: id ( ) ,
438
+ uri : uri. clone ( ) ,
439
+ } )
440
+ {
441
+ if codspeed:: utils:: running_with_codspeed_runner ( ) {
442
+ eprintln ! ( "Failed to send benchmark URI to runner: {error:?}" ) ;
443
+ }
439
444
}
440
445
}
441
446
You can’t perform that action at this time.
0 commit comments