File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,5 @@ mod hash;
11
11
mod iter;
12
12
mod num;
13
13
mod ops;
14
+ mod pattern;
14
15
mod slice;
Original file line number Diff line number Diff line change
1
+ use test:: black_box;
2
+ use test:: Bencher ;
3
+
4
+ #[ bench]
5
+ fn starts_with_char ( b : & mut Bencher ) {
6
+ let text = black_box ( "kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind" ) ;
7
+ b. iter ( || {
8
+ for _ in 0 ..1024 {
9
+ black_box ( text. starts_with ( 'k' ) ) ;
10
+ }
11
+ } )
12
+ }
13
+
14
+ #[ bench]
15
+ fn starts_with_str ( b : & mut Bencher ) {
16
+ let text = black_box ( "kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind" ) ;
17
+ b. iter ( || {
18
+ for _ in 0 ..1024 {
19
+ black_box ( text. starts_with ( "k" ) ) ;
20
+ }
21
+ } )
22
+ }
23
+
24
+
25
+ #[ bench]
26
+ fn ends_with_char ( b : & mut Bencher ) {
27
+ let text = black_box ( "kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind" ) ;
28
+ b. iter ( || {
29
+ for _ in 0 ..1024 {
30
+ black_box ( text. ends_with ( 'k' ) ) ;
31
+ }
32
+ } )
33
+ }
34
+
35
+ #[ bench]
36
+ fn ends_with_str ( b : & mut Bencher ) {
37
+ let text = black_box ( "kdjsfhlakfhlsghlkvcnljknfqiunvcijqenwodind" ) ;
38
+ b. iter ( || {
39
+ for _ in 0 ..1024 {
40
+ black_box ( text. ends_with ( "k" ) ) ;
41
+ }
42
+ } )
43
+ }
You can’t perform that action at this time.
0 commit comments