1- #![ allow( deprecated) ]
2-
31use criterion:: { black_box, criterion_group, criterion_main, Criterion } ;
42use memmem:: { Searcher , TwoWaySearcher } ;
5- #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
6- use sliceslice:: x86:: avx2:: { deprecated:: * , * } ;
73use std:: {
84 fs:: { self , File } ,
95 io:: { BufRead , BufReader } ,
@@ -29,7 +25,7 @@ fn search_short_haystack(c: &mut Criterion) {
2925 } ) ;
3026 } ) ;
3127
32- group. bench_function ( "TwoWaySearcher::search_in" , |b| {
28+ group. bench_function ( "memmem:: TwoWaySearcher::search_in" , |b| {
3329 let searchers = needles
3430 . iter ( )
3531 . map ( |needle| TwoWaySearcher :: new ( needle. as_bytes ( ) ) )
@@ -56,24 +52,14 @@ fn search_short_haystack(c: &mut Criterion) {
5652
5753 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
5854 {
59- group. bench_function ( "strstr_avx2_original" , |b| {
60- b. iter ( || {
61- for ( i, needle) in needles. iter ( ) . enumerate ( ) {
62- for haystack in & needles[ i..] {
63- black_box ( unsafe {
64- strstr_avx2_original ( haystack. as_bytes ( ) , needle. as_bytes ( ) )
65- } ) ;
66- }
67- }
68- } ) ;
69- } ) ;
55+ use sliceslice:: x86:: DynamicAvx2Searcher ;
7056
71- group. bench_function ( "strstr_avx2_rust " , |b| {
57+ group. bench_function ( "sse4_strstr::avx2_strstr_v2 " , |b| {
7258 b. iter ( || {
7359 for ( i, needle) in needles. iter ( ) . enumerate ( ) {
7460 for haystack in & needles[ i..] {
7561 black_box ( unsafe {
76- strstr_avx2_rust ( haystack. as_bytes ( ) , needle. as_bytes ( ) )
62+ sse4_strstr :: avx2_strstr_v2 ( haystack. as_bytes ( ) , needle. as_bytes ( ) )
7763 } ) ;
7864 }
7965 }
@@ -120,7 +106,7 @@ fn search_long_haystack(c: &mut Criterion) {
120106 } ) ;
121107 } ) ;
122108
123- group. bench_function ( "TwoWaySearcher::search_in" , |b| {
109+ group. bench_function ( "memmem:: TwoWaySearcher::search_in" , |b| {
124110 let searchers = needles
125111 . iter ( )
126112 . map ( |needle| TwoWaySearcher :: new ( needle. as_bytes ( ) ) )
@@ -143,24 +129,18 @@ fn search_long_haystack(c: &mut Criterion) {
143129
144130 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
145131 {
146- group. bench_function ( "strstr_avx2_original" , |b| {
132+ use sliceslice:: x86:: DynamicAvx2Searcher ;
133+
134+ group. bench_function ( "sse4_strstr::avx2_strstr_v2" , |b| {
147135 b. iter ( || {
148136 for needle in & needles {
149137 black_box ( unsafe {
150- strstr_avx2_original ( haystack. as_bytes ( ) , needle. as_bytes ( ) )
138+ sse4_strstr :: avx2_strstr_v2 ( haystack. as_bytes ( ) , needle. as_bytes ( ) )
151139 } ) ;
152140 }
153141 } ) ;
154142 } ) ;
155143
156- group. bench_function ( "strstr_avx2_rust" , |b| {
157- b. iter ( || {
158- for needle in & needles {
159- black_box ( unsafe { strstr_avx2_rust ( haystack. as_bytes ( ) , needle. as_bytes ( ) ) } ) ;
160- }
161- } ) ;
162- } ) ;
163-
164144 group. bench_function ( "DynamicAvx2Searcher::search_in" , |b| {
165145 let searchers = needles
166146 . iter ( )
0 commit comments