@@ -40,6 +40,10 @@ fn spaces(c: &mut Criterion) {
40
40
group. bench_function ( "stdlib_iter_position" , |b| {
41
41
b. iter ( || haystack. bytes ( ) . position ( |c| c == b' ' ) ) ;
42
42
} ) ;
43
+ group. bench_function ( "teddy" , |b| {
44
+ let searcher = aho_corasick:: packed:: Searcher :: new ( [ " " ] ) . unwrap ( ) ;
45
+ b. iter ( || searcher. find ( & haystack) . map ( |m| m. start ( ) ) ) ;
46
+ } ) ;
43
47
group. bench_function ( "memchr" , |b| {
44
48
b. iter ( || memchr:: memchr ( b' ' , haystack. as_bytes ( ) ) ) ;
45
49
} ) ;
@@ -69,6 +73,10 @@ fn xml3(c: &mut Criterion) {
69
73
. position ( |c| c == b'<' || c == b'>' || c == b'&' )
70
74
} ) ;
71
75
} ) ;
76
+ group. bench_function ( "teddy" , |b| {
77
+ let searcher = aho_corasick:: packed:: Searcher :: new ( [ "<" , ">" , "&" ] ) . unwrap ( ) ;
78
+ b. iter ( || searcher. find ( & haystack) . map ( |m| m. start ( ) ) ) ;
79
+ } ) ;
72
80
group. bench_function ( "memchr" , |b| {
73
81
b. iter ( || memchr:: memchr3 ( b'<' , b'>' , b'&' , haystack. as_bytes ( ) ) ) ;
74
82
} ) ;
@@ -98,6 +106,10 @@ fn xml5(c: &mut Criterion) {
98
106
. position ( |c| c == b'<' || c == b'>' || c == b'&' || c == b'\'' || c == b'"' )
99
107
} ) ;
100
108
} ) ;
109
+ group. bench_function ( "teddy" , |b| {
110
+ let searcher = aho_corasick:: packed:: Searcher :: new ( [ "<" , ">" , "&" , "'" , "\" " ] ) . unwrap ( ) ;
111
+ b. iter ( || searcher. find ( & haystack) . map ( |m| m. start ( ) ) ) ;
112
+ } ) ;
101
113
group. bench_function ( "memchr" , |b| {
102
114
b. iter ( || {
103
115
let bytes = haystack. as_bytes ( ) ;
@@ -174,6 +186,10 @@ fn big_16(c: &mut Criterion) {
174
186
} )
175
187
} ) ;
176
188
} ) ;
189
+ group. bench_function ( "teddy" , |b| {
190
+ let searcher = aho_corasick:: packed:: Searcher :: new ( b"ABCDEFGHIJKLMNOP" . iter ( ) . map ( |b| std:: array:: from_ref ( b) ) ) . unwrap ( ) ;
191
+ b. iter ( || searcher. find ( & haystack) . map ( |m| m. start ( ) ) ) ;
192
+ } ) ;
177
193
group. bench_function ( "memchr" , |b| {
178
194
b. iter ( || {
179
195
let bytes = haystack. as_bytes ( ) ;
@@ -253,6 +269,10 @@ fn big_16(c: &mut Criterion) {
253
269
} )
254
270
} ) ;
255
271
} ) ;
272
+ group. bench_function ( "teddy" , |b| {
273
+ let searcher = aho_corasick:: packed:: Searcher :: new ( b"ABCDEFGHIJKLMNOP" . iter ( ) . map ( |b| std:: array:: from_ref ( b) ) ) . unwrap ( ) ;
274
+ b. iter ( || searcher. find ( & haystack) . map ( |m| m. start ( ) ) ) ;
275
+ } ) ;
256
276
group. bench_function ( "memchr" , |b| {
257
277
b. iter ( || {
258
278
let bytes = haystack. as_bytes ( ) ;
0 commit comments