File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ publish = false
66
77[dependencies ]
88criterion = " 0.3"
9+ memchr = " 2.4"
910memmem = " 0.1"
1011sliceslice = { path = " .." }
1112sse4-strstr = { path = " sse4-strstr" , optional = true }
Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ fn search_short_haystack<M: Measurement>(c: &mut Criterion<M>) {
5656 } ) ;
5757 } ) ;
5858
59+ group. bench_function ( "memchr::memmem::find" , |b| {
60+ b. iter ( || {
61+ for ( i, needle) in needles. iter ( ) . enumerate ( ) {
62+ for haystack in & needles[ i..] {
63+ black_box ( memchr:: memmem:: find ( haystack. as_bytes ( ) , needle. as_bytes ( ) ) ) ;
64+ }
65+ }
66+ } ) ;
67+ } ) ;
68+
5969 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
6070 {
6171 use sliceslice:: x86:: DynamicAvx2Searcher ;
@@ -136,6 +146,14 @@ fn search_haystack<M: Measurement>(
136146 } ) ;
137147 } ) ;
138148
149+ group. bench_function ( "memchr::memmem::find" , |b| {
150+ b. iter ( || {
151+ for needle in & needles {
152+ black_box ( memchr:: memmem:: find ( haystack, needle. as_bytes ( ) ) ) ;
153+ }
154+ } ) ;
155+ } ) ;
156+
139157 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
140158 {
141159 use sliceslice:: x86:: DynamicAvx2Searcher ;
Original file line number Diff line number Diff line change @@ -49,6 +49,14 @@ fn search<M: Measurement>(c: &mut Criterion<M>) {
4949 } ,
5050 ) ;
5151
52+ group. bench_with_input (
53+ BenchmarkId :: new ( "memchr::memmem::find" , parameter) ,
54+ & size,
55+ |b, _| {
56+ b. iter ( || black_box ( memchr:: memmem:: find ( haystack, needle) ) ) ;
57+ } ,
58+ ) ;
59+
5260 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
5361 {
5462 use sliceslice:: x86:: DynamicAvx2Searcher ;
You can’t perform that action at this time.
0 commit comments