@@ -33,11 +33,11 @@ RUSTFLAGS="-C target-cpu=native" \
3333 cargo criterion --features bench_find bench_find --jobs $(nproc)
3434```
3535"# ]
36- use std:: env;
3736use std:: hint:: black_box;
3837use std:: time:: Duration ;
3938
4039use criterion:: { Criterion , Throughput } ;
40+ use stringtape:: BytesCowsAuto ;
4141
4242use aho_corasick:: AhoCorasick ;
4343use bstr:: ByteSlice ;
@@ -66,7 +66,7 @@ fn configure_bench() -> Criterion {
6666fn bench_substring_forward (
6767 g : & mut criterion:: BenchmarkGroup < ' _ , criterion:: measurement:: WallTime > ,
6868 haystack : & [ u8 ] ,
69- needles : & [ & [ u8 ] ] ,
69+ needles : & BytesCowsAuto ,
7070) {
7171 g. throughput ( Throughput :: Bytes ( haystack. len ( ) as u64 ) ) ;
7272
@@ -75,7 +75,7 @@ fn bench_substring_forward(
7575 if should_run ( "substring-forward/stringzilla::find" ) {
7676 g. bench_function ( "stringzilla::find" , |b| {
7777 b. iter ( || {
78- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
78+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
7979 let mut pos: usize = 0 ;
8080 while let Some ( found) = sz:: find ( & haystack[ pos..] , token) {
8181 pos += found + token. len ( ) ;
@@ -89,7 +89,7 @@ fn bench_substring_forward(
8989 if should_run ( "substring-forward/memmem::find" ) {
9090 g. bench_function ( "memmem::find" , |b| {
9191 b. iter ( || {
92- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
92+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
9393 let mut pos: usize = 0 ;
9494 while let Some ( found) = memmem:: find ( & haystack[ pos..] , token) {
9595 pos += found + token. len ( ) ;
@@ -103,7 +103,7 @@ fn bench_substring_forward(
103103 if should_run ( "substring-forward/memmem::Finder" ) {
104104 g. bench_function ( "memmem::Finder" , |b| {
105105 b. iter ( || {
106- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
106+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
107107 let finder = memmem:: Finder :: new ( token) ;
108108 let mut pos: usize = 0 ;
109109 while let Some ( found) = finder. find ( & haystack[ pos..] ) {
@@ -118,7 +118,7 @@ fn bench_substring_forward(
118118 if should_run ( "substring-forward/std::str::find" ) {
119119 g. bench_function ( "std::str::find" , |b| {
120120 b. iter ( || {
121- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
121+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
122122 let mut pos = 0 ;
123123 while let Some ( found) = haystack[ pos..] . find ( token) {
124124 pos += found + token. len ( ) ;
@@ -132,7 +132,7 @@ fn bench_substring_forward(
132132fn bench_substring_backward (
133133 g : & mut criterion:: BenchmarkGroup < ' _ , criterion:: measurement:: WallTime > ,
134134 haystack : & [ u8 ] ,
135- needles : & [ & [ u8 ] ] ,
135+ needles : & BytesCowsAuto ,
136136) {
137137 g. throughput ( Throughput :: Bytes ( haystack. len ( ) as u64 ) ) ;
138138
@@ -141,7 +141,7 @@ fn bench_substring_backward(
141141 if should_run ( "substring-backward/stringzilla::rfind" ) {
142142 g. bench_function ( "stringzilla::rfind" , |b| {
143143 b. iter ( || {
144- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
144+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
145145 let mut pos: Option < usize > = Some ( haystack. len ( ) ) ;
146146 while let Some ( end) = pos {
147147 if let Some ( found) = sz:: rfind ( & haystack[ ..end] , token) {
@@ -159,7 +159,7 @@ fn bench_substring_backward(
159159 if should_run ( "substring-backward/memmem::rfind" ) {
160160 g. bench_function ( "memmem::rfind" , |b| {
161161 b. iter ( || {
162- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
162+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
163163 let mut pos: Option < usize > = Some ( haystack. len ( ) ) ;
164164 while let Some ( end) = pos {
165165 if let Some ( found) = memmem:: rfind ( & haystack[ ..end] , token) {
@@ -177,7 +177,7 @@ fn bench_substring_backward(
177177 if should_run ( "substring-backward/memmem::FinderRev" ) {
178178 g. bench_function ( "memmem::FinderRev" , |b| {
179179 b. iter ( || {
180- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
180+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
181181 let finder = memmem:: FinderRev :: new ( token) ;
182182 let mut pos: Option < usize > = Some ( haystack. len ( ) ) ;
183183 while let Some ( end) = pos {
@@ -196,7 +196,7 @@ fn bench_substring_backward(
196196 if should_run ( "substring-backward/std::str::rfind" ) {
197197 g. bench_function ( "std::str::rfind" , |b| {
198198 b. iter ( || {
199- let token = black_box ( * tokens. next ( ) . unwrap ( ) ) ;
199+ let token = black_box ( tokens. next ( ) . unwrap ( ) ) ;
200200 let mut pos: Option < usize > = Some ( haystack. len ( ) ) ;
201201 while let Some ( end) = pos {
202202 if let Some ( found) = haystack[ ..end] . rfind ( token) {
@@ -214,7 +214,7 @@ fn bench_substring_backward(
214214fn bench_byteset_forward (
215215 g : & mut criterion:: BenchmarkGroup < ' _ , criterion:: measurement:: WallTime > ,
216216 haystack : & [ u8 ] ,
217- needles : & [ & [ u8 ] ] ,
217+ needles : & BytesCowsAuto ,
218218) {
219219 g. throughput ( Throughput :: Bytes ( 3 * haystack. len ( ) as u64 ) ) ;
220220
0 commit comments