File tree Expand file tree Collapse file tree 5 files changed +16
-7
lines changed Expand file tree Collapse file tree 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) {
112112#[ bench]
113113fn write_u128_max ( bh : & mut Bencher ) {
114114 bh. iter ( || {
115- std :: hint :: black_box ( format ! ( "{}" , u128 :: MAX ) ) ;
115+ test :: black_box ( format ! ( "{}" , u128 :: MAX ) ) ;
116116 } ) ;
117117}
118118
119119#[ bench]
120120fn write_u128_min ( bh : & mut Bencher ) {
121121 bh. iter ( || {
122122 let s = format ! ( "{}" , 0u128 ) ;
123- std :: hint :: black_box ( s) ;
123+ test :: black_box ( s) ;
124124 } ) ;
125125}
126126
127127#[ bench]
128128fn write_u64_max ( bh : & mut Bencher ) {
129129 bh. iter ( || {
130- std :: hint :: black_box ( format ! ( "{}" , u64 :: MAX ) ) ;
130+ test :: black_box ( format ! ( "{}" , u64 :: MAX ) ) ;
131131 } ) ;
132132}
133133
134134#[ bench]
135135fn write_u64_min ( bh : & mut Bencher ) {
136136 bh. iter ( || {
137- std :: hint :: black_box ( format ! ( "{}" , 0u64 ) ) ;
137+ test :: black_box ( format ! ( "{}" , 0u64 ) ) ;
138138 } ) ;
139139}
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ pub fn spin_loop() {
154154/// [`std::convert::identity`]: crate::convert::identity
155155#[ cfg_attr( not( miri) , inline) ]
156156#[ cfg_attr( miri, inline( never) ) ]
157- #[ unstable( feature = "test " , issue = "50297 " ) ]
157+ #[ unstable( feature = "bench_black_box " , issue = "64102 " ) ]
158158#[ cfg_attr( miri, allow( unused_mut) ) ]
159159pub fn black_box < T > ( mut dummy : T ) -> T {
160160 // 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 233233#![ feature( assert_matches) ]
234234#![ feature( associated_type_bounds) ]
235235#![ feature( atomic_mut_ptr) ]
236+ #![ feature( bench_black_box) ]
236237#![ feature( box_syntax) ]
237238#![ feature( c_variadic) ]
238239#![ feature( cfg_accessible) ]
Original file line number Diff line number Diff line change 11//! Benchmarking module.
2- pub use std:: hint:: black_box;
3-
42use super :: {
53 event:: CompletedTest ,
64 options:: BenchMode ,
@@ -16,6 +14,15 @@ use std::panic::{catch_unwind, AssertUnwindSafe};
1614use std:: sync:: { Arc , Mutex } ;
1715use std:: time:: { Duration , Instant } ;
1816
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+
1926/// Manager of the benchmarking runs.
2027///
2128/// This is fed into functions marked with `#[bench]` to allow for
Original file line number Diff line number Diff line change 2424#![ feature( rustc_private) ]
2525#![ feature( nll) ]
2626#![ feature( available_concurrency) ]
27+ #![ feature( bench_black_box) ]
2728#![ feature( internal_output_capture) ]
2829#![ feature( panic_unwind) ]
2930#![ feature( staged_api) ]
You can’t perform that action at this time.
0 commit comments