File tree 5 files changed +16
-7
lines changed
5 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -112,28 +112,28 @@ fn write_str_macro_debug(bh: &mut Bencher) {
112
112
#[ bench]
113
113
fn write_u128_max ( bh : & mut Bencher ) {
114
114
bh. iter ( || {
115
- std :: hint :: black_box ( format ! ( "{}" , u128 :: MAX ) ) ;
115
+ test :: black_box ( format ! ( "{}" , u128 :: MAX ) ) ;
116
116
} ) ;
117
117
}
118
118
119
119
#[ bench]
120
120
fn write_u128_min ( bh : & mut Bencher ) {
121
121
bh. iter ( || {
122
122
let s = format ! ( "{}" , 0u128 ) ;
123
- std :: hint :: black_box ( s) ;
123
+ test :: black_box ( s) ;
124
124
} ) ;
125
125
}
126
126
127
127
#[ bench]
128
128
fn write_u64_max ( bh : & mut Bencher ) {
129
129
bh. iter ( || {
130
- std :: hint :: black_box ( format ! ( "{}" , u64 :: MAX ) ) ;
130
+ test :: black_box ( format ! ( "{}" , u64 :: MAX ) ) ;
131
131
} ) ;
132
132
}
133
133
134
134
#[ bench]
135
135
fn write_u64_min ( bh : & mut Bencher ) {
136
136
bh. iter ( || {
137
- std :: hint :: black_box ( format ! ( "{}" , 0u64 ) ) ;
137
+ test :: black_box ( format ! ( "{}" , 0u64 ) ) ;
138
138
} ) ;
139
139
}
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ pub fn spin_loop() {
154
154
/// [`std::convert::identity`]: crate::convert::identity
155
155
#[ cfg_attr( not( miri) , inline) ]
156
156
#[ cfg_attr( miri, inline( never) ) ]
157
- #[ unstable( feature = "test " , issue = "50297 " ) ]
157
+ #[ unstable( feature = "bench_black_box " , issue = "64102 " ) ]
158
158
#[ cfg_attr( miri, allow( unused_mut) ) ]
159
159
pub fn black_box < T > ( mut dummy : T ) -> T {
160
160
// We need to "use" the argument in some way LLVM can't introspect, and on
Original file line number Diff line number Diff line change 233
233
#![ feature( assert_matches) ]
234
234
#![ feature( associated_type_bounds) ]
235
235
#![ feature( atomic_mut_ptr) ]
236
+ #![ feature( bench_black_box) ]
236
237
#![ feature( box_syntax) ]
237
238
#![ feature( c_variadic) ]
238
239
#![ feature( cfg_accessible) ]
Original file line number Diff line number Diff line change 1
1
//! Benchmarking module.
2
- pub use std:: hint:: black_box;
3
-
4
2
use super :: {
5
3
event:: CompletedTest ,
6
4
options:: BenchMode ,
@@ -16,6 +14,15 @@ use std::panic::{catch_unwind, AssertUnwindSafe};
16
14
use std:: sync:: { Arc , Mutex } ;
17
15
use std:: time:: { Duration , Instant } ;
18
16
17
+ /// An identity function that *__hints__* to the compiler to be maximally pessimistic about what
18
+ /// `black_box` could do.
19
+ ///
20
+ /// See [`std::hint::black_box`] for details.
21
+ #[ inline( always) ]
22
+ pub fn black_box < T > ( dummy : T ) -> T {
23
+ std:: hint:: black_box ( dummy)
24
+ }
25
+
19
26
/// Manager of the benchmarking runs.
20
27
///
21
28
/// This is fed into functions marked with `#[bench]` to allow for
Original file line number Diff line number Diff line change 24
24
#![ feature( rustc_private) ]
25
25
#![ feature( nll) ]
26
26
#![ feature( available_concurrency) ]
27
+ #![ feature( bench_black_box) ]
27
28
#![ feature( internal_output_capture) ]
28
29
#![ feature( panic_unwind) ]
29
30
#![ feature( staged_api) ]
You can’t perform that action at this time.
0 commit comments