@@ -15,6 +15,7 @@ extern crate rand;
15
15
extern crate btree_rewrite;
16
16
17
17
mod multiply_shift;
18
+ mod sip_opt;
18
19
19
20
use std:: process:: { Stdio , Command } ;
20
21
use std:: io:: Result as IoResult ;
@@ -128,9 +129,9 @@ macro_rules! hash_benches {
128
129
use blake2_rfc:: blake2s:: Blake2s ;
129
130
use _fnv:: FnvHasher as Fnv ;
130
131
use farmhash:: FarmHasher as Farm ;
131
- use std:: hash:: Hasher ;
132
- use std:: collections:: hash_state:: { DefaultState , HashState } ;
132
+ use std:: hash:: { Hasher , BuildHasher , BuildHasherDefault } ;
133
133
use multiply_shift:: HornerHasher ;
134
+ use sip_opt:: SipHasher as SipOpt ;
134
135
135
136
use std:: collections:: HashMap ;
136
137
use test:: { black_box, Bencher } ;
@@ -140,13 +141,13 @@ macro_rules! hash_benches {
140
141
fn hasher_bench<H >( b: B , len: usize )
141
142
where H : Hasher + Default
142
143
{
143
- let hash_state = DefaultState :: <H >:: default ( ) ;
144
+ let hash_state = BuildHasherDefault :: <H >:: default ( ) ;
144
145
let bytes: Vec <u8 > = ( 0 ..100 ) . cycle( ) . take( len) . collect( ) ;
145
146
let bytes = black_box( bytes) ;
146
147
147
148
b. bytes = bytes. len( ) as u64 ;
148
149
b. iter( || {
149
- let mut hasher = hash_state. hasher ( ) ;
150
+ let mut hasher = hash_state. build_hasher ( ) ;
150
151
hasher. write( & bytes) ;
151
152
hasher. finish( )
152
153
} ) ;
@@ -163,9 +164,9 @@ macro_rules! hash_benches {
163
164
b. bytes = ( len * num_strings) as u64 ;
164
165
b. iter( || {
165
166
// don't reserve space to be fair to BTree
166
- let mut map = HashMap :: with_hash_state ( DefaultState :: <H >:: default ( ) ) ;
167
+ let mut map = HashMap :: with_hasher ( BuildHasherDefault :: <H >:: default ( ) ) ;
167
168
for chunk in data. chunks( len) {
168
- * map. entry( chunk) . or_insert( 0 ) += 1 ;
169
+ * map. entry( chunk) . or_insert( 0usize ) += 1 ;
169
170
}
170
171
map
171
172
} ) ;
@@ -183,15 +184,15 @@ macro_rules! hash_benches {
183
184
b. bytes = ( len * num_strings) as u64 ;
184
185
b. iter( || {
185
186
// don't reserve space to be fair to BTree
186
- let mut map = HashMap :: with_hash_state ( DefaultState :: <H >:: default ( ) ) ;
187
+ let mut map = HashMap :: with_hasher ( BuildHasherDefault :: <H >:: default ( ) ) ;
187
188
for chunk in data. chunks( len) {
188
- * map. entry( chunk) . or_insert( 0 ) += 1 ;
189
+ * map. entry( chunk) . or_insert( 0usize ) += 1 ;
189
190
}
190
191
map
191
192
} ) ;
192
193
}
193
194
194
- #[ bench] fn bytes_000000001( b: B ) { hasher_bench:: <$Impl>( b, 1 ) }
195
+ // #[bench] fn bytes_000000001(b: B) { hasher_bench::<$Impl>(b, 1) }
195
196
#[ bench] fn bytes_000000002( b: B ) { hasher_bench:: <$Impl>( b, 2 ) }
196
197
#[ bench] fn bytes_000000004( b: B ) { hasher_bench:: <$Impl>( b, 4 ) }
197
198
#[ bench] fn bytes_000000008( b: B ) { hasher_bench:: <$Impl>( b, 8 ) }
@@ -200,11 +201,11 @@ macro_rules! hash_benches {
200
201
#[ bench] fn bytes_000000064( b: B ) { hasher_bench:: <$Impl>( b, 64 ) }
201
202
#[ bench] fn bytes_000000128( b: B ) { hasher_bench:: <$Impl>( b, 128 ) }
202
203
#[ bench] fn bytes_000000256( b: B ) { hasher_bench:: <$Impl>( b, 256 ) }
203
- #[ bench] fn bytes_000000512( b: B ) { hasher_bench:: <$Impl>( b, 512 ) }
204
- #[ bench] fn bytes_000001024( b: B ) { hasher_bench:: <$Impl>( b, 1024 ) }
205
- #[ bench] fn bytes_000002048( b: B ) { hasher_bench:: <$Impl>( b, 2048 ) }
204
+ // #[bench] fn bytes_000000512(b: B) { hasher_bench::<$Impl>(b, 512) }
205
+ // #[bench] fn bytes_000001024(b: B) { hasher_bench::<$Impl>(b, 1024) }
206
+ // #[bench] fn bytes_000002048(b: B) { hasher_bench::<$Impl>(b, 2048) }
206
207
207
- #[ bench] fn mapcountsparse_000000001( b: B ) { map_bench_sparse:: <$Impl>( b, 1 ) }
208
+ // #[bench] fn mapcountsparse_000000001(b: B) { map_bench_sparse::<$Impl>(b, 1) }
208
209
#[ bench] fn mapcountsparse_000000002( b: B ) { map_bench_sparse:: <$Impl>( b, 2 ) }
209
210
#[ bench] fn mapcountsparse_000000004( b: B ) { map_bench_sparse:: <$Impl>( b, 4 ) }
210
211
#[ bench] fn mapcountsparse_000000008( b: B ) { map_bench_sparse:: <$Impl>( b, 8 ) }
@@ -213,11 +214,11 @@ macro_rules! hash_benches {
213
214
#[ bench] fn mapcountsparse_000000064( b: B ) { map_bench_sparse:: <$Impl>( b, 64 ) }
214
215
#[ bench] fn mapcountsparse_000000128( b: B ) { map_bench_sparse:: <$Impl>( b, 128 ) }
215
216
#[ bench] fn mapcountsparse_000000256( b: B ) { map_bench_sparse:: <$Impl>( b, 256 ) }
216
- #[ bench] fn mapcountsparse_000000512( b: B ) { map_bench_sparse:: <$Impl>( b, 512 ) }
217
- #[ bench] fn mapcountsparse_000001024( b: B ) { map_bench_sparse:: <$Impl>( b, 1024 ) }
218
- #[ bench] fn mapcountsparse_000002048( b: B ) { map_bench_sparse:: <$Impl>( b, 2048 ) }
217
+ // #[bench] fn mapcountsparse_000000512(b: B) { map_bench_sparse::<$Impl>(b, 512) }
218
+ // #[bench] fn mapcountsparse_000001024(b: B) { map_bench_sparse::<$Impl>(b, 1024) }
219
+ // #[bench] fn mapcountsparse_000002048(b: B) { map_bench_sparse::<$Impl>(b, 2048) }
219
220
220
- #[ bench] fn mapcountdense_000000001( b: B ) { map_bench_dense:: <$Impl>( b, 1 ) }
221
+ // #[bench] fn mapcountdense_000000001(b: B) { map_bench_dense::<$Impl>(b, 1) }
221
222
#[ bench] fn mapcountdense_000000002( b: B ) { map_bench_dense:: <$Impl>( b, 2 ) }
222
223
#[ bench] fn mapcountdense_000000004( b: B ) { map_bench_dense:: <$Impl>( b, 4 ) }
223
224
#[ bench] fn mapcountdense_000000008( b: B ) { map_bench_dense:: <$Impl>( b, 8 ) }
@@ -226,16 +227,15 @@ macro_rules! hash_benches {
226
227
#[ bench] fn mapcountdense_000000064( b: B ) { map_bench_dense:: <$Impl>( b, 64 ) }
227
228
#[ bench] fn mapcountdense_000000128( b: B ) { map_bench_dense:: <$Impl>( b, 128 ) }
228
229
#[ bench] fn mapcountdense_000000256( b: B ) { map_bench_dense:: <$Impl>( b, 256 ) }
229
- #[ bench] fn mapcountdense_000000512( b: B ) { map_bench_dense:: <$Impl>( b, 512 ) }
230
- #[ bench] fn mapcountdense_000001024( b: B ) { map_bench_dense:: <$Impl>( b, 1024 ) }
231
- #[ bench] fn mapcountdense_000002048( b: B ) { map_bench_dense:: <$Impl>( b, 2048 ) }
230
+ // #[bench] fn mapcountdense_000000512(b: B) { map_bench_dense::<$Impl>(b, 512) }
231
+ // #[bench] fn mapcountdense_000001024(b: B) { map_bench_dense::<$Impl>(b, 1024) }
232
+ // #[bench] fn mapcountdense_000002048(b: B) { map_bench_dense::<$Impl>(b, 2048) }
232
233
}
233
234
}
234
235
235
236
macro_rules! tree_benches {
236
237
( $Impl: ty) => {
237
238
use std:: collections:: BTreeMap as StdBTree ;
238
- use btree_rewrite:: map:: BTreeMap as NewBTree ;
239
239
240
240
use test:: { black_box, Bencher } ;
241
241
pub type B <' a> = & ' a mut Bencher ;
@@ -275,7 +275,7 @@ macro_rules! tree_benches {
275
275
}
276
276
277
277
278
- #[ bench] fn mapcountsparse_000000001( b: B ) { map_bench_sparse( b, 1 ) }
278
+ // #[bench] fn mapcountsparse_000000001(b: B) { map_bench_sparse(b, 1) }
279
279
#[ bench] fn mapcountsparse_000000002( b: B ) { map_bench_sparse( b, 2 ) }
280
280
#[ bench] fn mapcountsparse_000000004( b: B ) { map_bench_sparse( b, 4 ) }
281
281
#[ bench] fn mapcountsparse_000000008( b: B ) { map_bench_sparse( b, 8 ) }
@@ -284,11 +284,11 @@ macro_rules! tree_benches {
284
284
#[ bench] fn mapcountsparse_000000064( b: B ) { map_bench_sparse( b, 64 ) }
285
285
#[ bench] fn mapcountsparse_000000128( b: B ) { map_bench_sparse( b, 128 ) }
286
286
#[ bench] fn mapcountsparse_000000256( b: B ) { map_bench_sparse( b, 256 ) }
287
- #[ bench] fn mapcountsparse_000000512( b: B ) { map_bench_sparse( b, 512 ) }
288
- #[ bench] fn mapcountsparse_000001024( b: B ) { map_bench_sparse( b, 1024 ) }
289
- #[ bench] fn mapcountsparse_000002048( b: B ) { map_bench_sparse( b, 2048 ) }
287
+ // #[bench] fn mapcountsparse_000000512(b: B) { map_bench_sparse(b, 512) }
288
+ // #[bench] fn mapcountsparse_000001024(b: B) { map_bench_sparse(b, 1024) }
289
+ // #[bench] fn mapcountsparse_000002048(b: B) { map_bench_sparse(b, 2048) }
290
290
291
- #[ bench] fn mapcountdense_000000001( b: B ) { map_bench_dense( b, 1 ) }
291
+ // #[bench] fn mapcountdense_000000001(b: B) { map_bench_dense(b, 1) }
292
292
#[ bench] fn mapcountdense_000000002( b: B ) { map_bench_dense( b, 2 ) }
293
293
#[ bench] fn mapcountdense_000000004( b: B ) { map_bench_dense( b, 4 ) }
294
294
#[ bench] fn mapcountdense_000000008( b: B ) { map_bench_dense( b, 8 ) }
@@ -297,9 +297,9 @@ macro_rules! tree_benches {
297
297
#[ bench] fn mapcountdense_000000064( b: B ) { map_bench_dense( b, 64 ) }
298
298
#[ bench] fn mapcountdense_000000128( b: B ) { map_bench_dense( b, 128 ) }
299
299
#[ bench] fn mapcountdense_000000256( b: B ) { map_bench_dense( b, 256 ) }
300
- #[ bench] fn mapcountdense_000000512( b: B ) { map_bench_dense( b, 512 ) }
301
- #[ bench] fn mapcountdense_000001024( b: B ) { map_bench_dense( b, 1024 ) }
302
- #[ bench] fn mapcountdense_000002048( b: B ) { map_bench_dense( b, 2048 ) }
300
+ // #[bench] fn mapcountdense_000000512(b: B) { map_bench_dense(b, 512) }
301
+ // #[bench] fn mapcountdense_000001024(b: B) { map_bench_dense(b, 1024) }
302
+ // #[bench] fn mapcountdense_000002048(b: B) { map_bench_dense(b, 2048) }
303
303
}
304
304
}
305
305
@@ -308,6 +308,7 @@ macro_rules! tree_benches {
308
308
#[ cfg( test) ] mod farm { hash_benches ! { Farm } }
309
309
#[ cfg( test) ] mod fnv { hash_benches ! { Fnv } }
310
310
#[ cfg( test) ] mod horner { hash_benches ! { HornerHasher } }
311
+ #[ cfg( test) ] mod sip_opt_b { hash_benches ! { SipOpt } }
311
312
312
313
// one day?
313
314
@@ -316,7 +317,5 @@ macro_rules! tree_benches {
316
317
// #[cfg(test)] mod murmur { hash_benches!{MurMur}}
317
318
318
319
319
- #[ cfg( test) ] mod btree { tree_benches ! { StdBTree <& [ u8 ] , i32 >} }
320
- #[ cfg( test) ] mod btreenew { tree_benches ! { NewBTree <& [ u8 ] , i32 >} }
321
-
322
-
320
+ // #[cfg(test)] mod btree { tree_benches!{StdBTree<&[u8], usize>} }
321
+ // #[cfg(test)] mod btreenew { tree_benches!{NewBTree<&[u8], i32>} }
0 commit comments