@@ -243,6 +243,50 @@ fn attributes(c: &mut Criterion) {
243243 assert_eq ! ( count, 150 ) ;
244244 } )
245245 } ) ;
246+
247+ group. finish ( ) ;
248+ }
249+
250+ /// Benchmarks normalizing attribute values
251+ fn attribute_value_normalization ( c : & mut Criterion ) {
252+ let mut group = c. benchmark_group ( "attribute_value_normalization" ) ;
253+
254+ group. bench_function ( "noop_short" , |b| {
255+ b. iter ( || {
256+ black_box ( unescape ( "foobar" ) ) . unwrap ( ) ;
257+ } )
258+ } ) ;
259+
260+ group. bench_function ( "noop_long" , |b| {
261+ b. iter ( || {
262+ black_box ( unescape ( "just a bit of text without any entities" ) ) . unwrap ( ) ;
263+ } )
264+ } ) ;
265+
266+ group. bench_function ( "replacement_chars" , |b| {
267+ b. iter ( || {
268+ black_box ( unescape ( "just a bit\n of text without\t any entities" ) ) . unwrap ( ) ;
269+ } )
270+ } ) ;
271+
272+ group. bench_function ( "char_reference" , |b| {
273+ b. iter ( || {
274+ let text = "prefix "some stuff","more stuff"" ;
275+ black_box ( unescape ( text) ) . unwrap ( ) ;
276+ let text = "&<" ;
277+ black_box ( unescape ( text) ) . unwrap ( ) ;
278+ } )
279+ } ) ;
280+
281+ group. bench_function ( "entity_reference" , |b| {
282+ b. iter ( || {
283+ let text = "age > 72 && age < 21" ;
284+ black_box ( unescape ( text) ) . unwrap ( ) ;
285+ let text = ""what's that?"" ;
286+ black_box ( unescape ( text) ) . unwrap ( ) ;
287+ } )
288+ } ) ;
289+
246290 group. finish ( ) ;
247291}
248292
@@ -355,6 +399,7 @@ criterion_group!(
355399 read_resolved_event_into,
356400 one_event,
357401 attributes,
402+ attribute_value_normalization,
358403 escaping,
359404 unescaping,
360405) ;
0 commit comments