@@ -13,15 +13,17 @@ criterion_group!(
1313 bench_parse_uri,
1414 bench_parse_iri,
1515 bench_build,
16- bench_normalize,
16+ bench_normalize_uri,
17+ bench_normalize_iri,
1718 bench_resolve,
1819 bench_top100,
1920) ;
2021criterion_main ! ( benches) ;
2122
2223const PARSE_URI_CASE : & str = "https://user@example.com/search?q=%E6%B5%8B%E8%AF%95#fragment" ;
2324const PARSE_IRI_CASE : & str = "https://用户@测试.com/search?q=我们测试解析IRI#fragment" ;
24- const NORMALIZE_CASE : & str = "eXAMPLE://a/./b/../b/%63/%7bfoo%7d" ;
25+ const NORMALIZE_URI_CASE : & str = "eXAMPLE://a/./b/../b/%63/%7bfoo%7d" ;
26+ const NORMALIZE_IRI_CASE : & str = "https://%E7%94%A8%E6%88%B7@%E6%B5%8B%E8%AF%95.com/search?q=%E6%88%91%E4%BB%AC%E6%B5%8B%E8%AF%95%E8%A7%A3%E6%9E%90IRI#fragment" ;
2527const RESOLVE_CASE_BASE : & str = "http://example.com/foo/bar/baz/quz" ;
2628const RESOLVE_CASE_REF : & str = "../../../qux/./quux/../corge" ;
2729
@@ -89,11 +91,23 @@ fn bench_build(c: &mut Criterion) {
8991 group. finish ( ) ;
9092}
9193
92- fn bench_normalize ( c : & mut Criterion ) {
93- let r_fluent = Uri :: parse ( NORMALIZE_CASE ) . unwrap ( ) ;
94- let r_iri = UriStr :: new ( NORMALIZE_CASE ) . unwrap ( ) ;
94+ fn bench_normalize_uri ( c : & mut Criterion ) {
95+ let r_fluent = Uri :: parse ( NORMALIZE_URI_CASE ) . unwrap ( ) ;
96+ let r_iri = UriStr :: new ( NORMALIZE_URI_CASE ) . unwrap ( ) ;
9597
96- let mut group = c. benchmark_group ( "normalize" ) ;
98+ let mut group = c. benchmark_group ( "normalize-uri" ) ;
99+ group. bench_function ( "fluent-uri" , |b| b. iter ( || r_fluent. normalize ( ) ) ) ;
100+ group. bench_function ( "iri-string" , |b| {
101+ b. iter ( || r_iri. normalize ( ) . to_dedicated_string ( ) )
102+ } ) ;
103+ group. finish ( ) ;
104+ }
105+
106+ fn bench_normalize_iri ( c : & mut Criterion ) {
107+ let r_fluent = Iri :: parse ( NORMALIZE_IRI_CASE ) . unwrap ( ) ;
108+ let r_iri = IriStr :: new ( NORMALIZE_IRI_CASE ) . unwrap ( ) ;
109+
110+ let mut group = c. benchmark_group ( "normalize-iri" ) ;
97111 group. bench_function ( "fluent-uri" , |b| b. iter ( || r_fluent. normalize ( ) ) ) ;
98112 group. bench_function ( "iri-string" , |b| {
99113 b. iter ( || r_iri. normalize ( ) . to_dedicated_string ( ) )
0 commit comments