@@ -49,6 +49,46 @@ fn to_ascii_merged(bench: &mut Bencher) {
49
49
bench. iter ( || config. to_ascii ( black_box ( encoded) ) ) ;
50
50
}
51
51
52
+ fn to_ascii_cow_plain ( bench : & mut Bencher ) {
53
+ let encoded = "example.com" . as_bytes ( ) ;
54
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
55
+ }
56
+
57
+ fn to_ascii_cow_leading_digit ( bench : & mut Bencher ) {
58
+ let encoded = "1test.example" . as_bytes ( ) ;
59
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
60
+ }
61
+
62
+ fn to_ascii_cow_unicode_mixed ( bench : & mut Bencher ) {
63
+ let encoded = "مثال.example" . as_bytes ( ) ;
64
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
65
+ }
66
+
67
+ fn to_ascii_cow_punycode_mixed ( bench : & mut Bencher ) {
68
+ let encoded = "xn--mgbh0fb.example" . as_bytes ( ) ;
69
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
70
+ }
71
+
72
+ fn to_ascii_cow_unicode_ltr ( bench : & mut Bencher ) {
73
+ let encoded = "නම.උදාහරණ" . as_bytes ( ) ;
74
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
75
+ }
76
+
77
+ fn to_ascii_cow_punycode_ltr ( bench : & mut Bencher ) {
78
+ let encoded = "xn--r0co.xn--ozc8dl2c3bxd" . as_bytes ( ) ;
79
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
80
+ }
81
+
82
+ fn to_ascii_cow_unicode_rtl ( bench : & mut Bencher ) {
83
+ let encoded = "الاسم.مثال" . as_bytes ( ) ;
84
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
85
+ }
86
+
87
+ fn to_ascii_cow_punycode_rtl ( bench : & mut Bencher ) {
88
+ let encoded = "xn--mgba0b1dh.xn--mgbh0fb" . as_bytes ( ) ;
89
+ bench. iter ( || idna:: domain_to_ascii_cow ( black_box ( encoded) , idna:: AsciiDenyList :: URL ) ) ;
90
+ }
91
+
52
92
benchmark_group ! (
53
93
benches,
54
94
to_unicode_puny_label,
@@ -58,5 +98,13 @@ benchmark_group!(
58
98
to_ascii_already_puny_label,
59
99
to_ascii_simple,
60
100
to_ascii_merged,
101
+ to_ascii_cow_plain,
102
+ to_ascii_cow_leading_digit,
103
+ to_ascii_cow_unicode_mixed,
104
+ to_ascii_cow_punycode_mixed,
105
+ to_ascii_cow_unicode_ltr,
106
+ to_ascii_cow_punycode_ltr,
107
+ to_ascii_cow_unicode_rtl,
108
+ to_ascii_cow_punycode_rtl,
61
109
) ;
62
110
benchmark_main ! ( benches) ;
0 commit comments