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};
99use codspeed:: walltime_results:: WalltimeResults ;
1010use std:: {
1111 io:: { self , Write } ,
12- os:: unix:: process:: ExitStatusExt ,
1312 path:: { Path , PathBuf } ,
1413} ;
1514
15+ #[ cfg( unix) ]
16+ use std:: os:: unix:: process:: ExitStatusExt ;
17+
1618struct BenchToRun {
1719 bench_path : PathBuf ,
1820 bench_name : String ,
@@ -156,13 +158,21 @@ pub fn run_benches(
156158 if status. success ( ) {
157159 Ok ( ( ) )
158160 } 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}" ) ;
163169
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+ }
166176 }
167177 } ) ?;
168178 eprintln ! ( "Done running {bench_name}" ) ;
Original file line number Diff line number Diff line change 11pub mod codspeed;
2+
3+ #[ cfg( unix) ]
24pub mod fifo;
5+
36mod macros;
47mod measurement;
58mod request;
Original file line number Diff line number Diff line change 11//! WARNING: Has to be in sync with `runner`.
22
3+ #[ cfg( unix) ]
34pub const RUNNER_CTL_FIFO : & str = "/tmp/runner.ctl.fifo" ;
5+ #[ cfg( unix) ]
46pub const RUNNER_ACK_FIFO : & str = "/tmp/runner.ack.fifo" ;
57
68#[ derive( serde:: Serialize , serde:: Deserialize , Debug , PartialEq ) ]
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ mod tests {
7171 assert_eq ! ( relative_path, path_dir. canonicalize( ) . unwrap( ) ) ;
7272 }
7373
74+ #[ cfg( unix) ]
7475 #[ test]
7576 fn test_get_git_relative_path_not_found_with_symlink ( ) {
7677 let dir = tempdir ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -297,12 +297,17 @@ mod codspeed {
297297 ) {
298298 let ( uri, bench_name) = create_uri_and_name ( id, c) ;
299299
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+ }
306311 }
307312 }
308313
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ pub(crate) trait Routine<M: Measurement, T: ?Sized> {
192192 }
193193
194194 let m_elapsed = {
195+ #[ cfg( unix) ]
195196 let _guard = codspeed:: fifo:: BenchGuard :: new_with_runner_fifo ( ) ;
196197 self . bench ( measurement, & m_iters, parameter)
197198 } ;
Original file line number Diff line number Diff line change @@ -657,6 +657,7 @@ impl<'a> BenchContext<'a> {
657657
658658 let bench_overheads = timer. bench_overheads ( ) ;
659659
660+ #[ cfg( unix) ]
660661 let _guard = codspeed:: fifo:: BenchGuard :: new_with_runner_fifo ( ) ;
661662 while {
662663 // Conditions for when sampling is over:
@@ -811,6 +812,7 @@ impl<'a> BenchContext<'a> {
811812 elapsed_picos = elapsed_picos. saturating_add ( progress_picos) ;
812813 }
813814 }
815+ #[ cfg( unix) ]
814816 core:: mem:: drop ( _guard) ;
815817
816818 // Reset flag for ignoring allocations.
Original file line number Diff line number Diff line change @@ -430,12 +430,17 @@ mod codspeed {
430430 bench_context. samples . time_samples . iter ( ) . map ( |s| s. duration . picos / 1_000 ) . collect ( ) ;
431431 let max_time_ns = bench_context. options . max_time . map ( |t| t. as_nanos ( ) ) ;
432432
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+ }
439444 }
440445 }
441446
You can’t perform that action at this time.
0 commit comments