11use std:: io:: { Cursor , Read , Seek } ;
22
3- use criterion:: { black_box , criterion_group, criterion_main, BatchSize , Criterion } ;
3+ use criterion:: { criterion_group, criterion_main, BatchSize , Criterion } ;
44use deku:: prelude:: * ;
55
66#[ cfg( feature = "bits" ) ]
@@ -55,7 +55,7 @@ fn criterion_benchmark(c: &mut Criterion) {
5555 } ) ;
5656 c. bench_function ( "deku_write_byte" , |b| {
5757 b. iter ( || {
58- deku_write ( black_box ( & DekuBytes {
58+ deku_write ( std :: hint :: black_box ( & DekuBytes {
5959 data_00 : 0x00 ,
6060 data_01 : 0x02 ,
6161 data_02 : 0x03 ,
@@ -74,7 +74,7 @@ fn criterion_benchmark(c: &mut Criterion) {
7474 #[ cfg( feature = "bits" ) ]
7575 c. bench_function ( "deku_write_bits" , |b| {
7676 b. iter ( || {
77- deku_write ( black_box ( & DekuBits {
77+ deku_write ( std :: hint :: black_box ( & DekuBits {
7878 data_01 : 0x01 ,
7979 data_02 : 0x03 ,
8080 data_03 : 0x06 ,
@@ -91,7 +91,7 @@ fn criterion_benchmark(c: &mut Criterion) {
9191 )
9292 } ) ;
9393 c. bench_function ( "deku_write_enum" , |b| {
94- b. iter ( || deku_write ( black_box ( & DekuEnum :: VariantA ( 0x02 ) ) ) )
94+ b. iter ( || deku_write ( std :: hint :: black_box ( & DekuEnum :: VariantA ( 0x02 ) ) ) )
9595 } ) ;
9696
9797 let deku_write_vec_input = DekuVec {
@@ -107,7 +107,7 @@ fn criterion_benchmark(c: &mut Criterion) {
107107 )
108108 } ) ;
109109 c. bench_function ( "deku_write_vec" , |b| {
110- b. iter ( || deku_write ( black_box ( & deku_write_vec_input) ) )
110+ b. iter ( || deku_write ( std :: hint :: black_box ( & deku_write_vec_input) ) )
111111 } ) ;
112112}
113113
@@ -138,38 +138,38 @@ pub fn read_all_vs_count_vs_read_exact(c: &mut Criterion) {
138138 }
139139
140140 c. bench_function ( "read_all_bytes" , |b| {
141- b. iter ( || AllWrapper :: from_bytes ( black_box ( ( & [ 1 ; 1500 ] , 0 ) ) ) )
141+ b. iter ( || AllWrapper :: from_bytes ( std :: hint :: black_box ( ( & [ 1 ; 1500 ] , 0 ) ) ) )
142142 } ) ;
143143
144144 c. bench_function ( "read_all" , |b| {
145145 b. iter ( || {
146146 let mut cursor = Cursor :: new ( [ 1u8 ; 1500 ] . as_ref ( ) ) ;
147147 let mut reader = Reader :: new ( & mut cursor) ;
148- AllWrapper :: from_reader_with_ctx ( black_box ( & mut reader) , ( ) )
148+ AllWrapper :: from_reader_with_ctx ( std :: hint :: black_box ( & mut reader) , ( ) )
149149 } )
150150 } ) ;
151151
152152 c. bench_function ( "count_specialize" , |b| {
153153 b. iter ( || {
154154 let mut cursor = Cursor :: new ( [ 1u8 ; 1500 ] . as_ref ( ) ) ;
155155 let mut reader = Reader :: new ( & mut cursor) ;
156- CountWrapper :: from_reader_with_ctx ( black_box ( & mut reader) , ( ) )
156+ CountWrapper :: from_reader_with_ctx ( std :: hint :: black_box ( & mut reader) , ( ) )
157157 } )
158158 } ) ;
159159
160160 c. bench_function ( "count_from_u8_specialize" , |b| {
161161 b. iter ( || {
162162 let mut cursor = Cursor :: new ( [ 1u8 ; 1500 ] . as_ref ( ) ) ;
163163 let mut reader = Reader :: new ( & mut cursor) ;
164- CountWrapper :: from_reader_with_ctx ( black_box ( & mut reader) , ( ) )
164+ CountWrapper :: from_reader_with_ctx ( std :: hint :: black_box ( & mut reader) , ( ) )
165165 } )
166166 } ) ;
167167
168168 c. bench_function ( "count_no_specialize" , |b| {
169169 b. iter ( || {
170170 let mut cursor = Cursor :: new ( [ 1u8 ; 1500 ] . as_ref ( ) ) ;
171171 let mut reader = Reader :: new ( & mut cursor) ;
172- CountNonSpecialize :: from_reader_with_ctx ( black_box ( & mut reader) , ( ) )
172+ CountNonSpecialize :: from_reader_with_ctx ( std :: hint :: black_box ( & mut reader) , ( ) )
173173 } )
174174 } ) ;
175175}
0 commit comments