File tree 3 files changed +27
-0
lines changed
3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ publish = false
6
6
7
7
[dependencies ]
8
8
criterion = " 0.3"
9
+ memchr = " 2.4"
9
10
memmem = " 0.1"
10
11
sliceslice = { path = " .." }
11
12
sse4-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>) {
56
56
} ) ;
57
57
} ) ;
58
58
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
+
59
69
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
60
70
{
61
71
use sliceslice:: x86:: DynamicAvx2Searcher ;
@@ -136,6 +146,14 @@ fn search_haystack<M: Measurement>(
136
146
} ) ;
137
147
} ) ;
138
148
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
+
139
157
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
140
158
{
141
159
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>) {
49
49
} ,
50
50
) ;
51
51
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
+
52
60
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
53
61
{
54
62
use sliceslice:: x86:: DynamicAvx2Searcher ;
You can’t perform that action at this time.
0 commit comments