11#![ warn( rust_2018_idioms) ]
2-
32#![ feature( test) ]
43extern crate test; // Still required, see rust-lang/rust#55133
54
65use std:: default:: Default ;
7- use std:: io;
86use std:: fs:: File ;
7+ use std:: io;
98
109use test:: Bencher ;
1110
1211use encoding_rs as enc;
1312use html5ever:: driver:: ParseOpts ;
1413use html5ever:: parse_document;
15- use markup5ever_rcdom:: { SerializableHandle , RcDom } ;
1614use html5ever:: serialize as rc_serialize;
15+ use markup5ever_rcdom:: { RcDom , SerializableHandle } ;
1716
1817use marked;
19- use marked:: { Decoder , EncodingHint } ;
2018use marked:: chain_filters;
2119use marked:: filter;
2220use marked:: html:: parse_buffered;
21+ use marked:: { Decoder , EncodingHint } ;
2322
2423#[ bench]
2524fn b00_round_trip_rcdom ( b : & mut Bencher ) {
2625 b. iter ( || {
27- let parser_sink =
28- parse_document ( RcDom :: default ( ) , ParseOpts :: default ( ) ) ;
26+ let parser_sink = parse_document ( RcDom :: default ( ) , ParseOpts :: default ( ) ) ;
2927 let decoder = Decoder :: new ( enc:: UTF_8 , parser_sink) ;
30- let mut fin = sample_file ( "github-dekellum.html" )
31- . expect ( "sample_file" ) ;
28+ let mut fin = sample_file ( "github-dekellum.html" ) . expect ( "sample_file" ) ;
3229 let doc = decoder. read_to_end ( & mut fin) . expect ( "parse" ) ;
3330 let mut out = Vec :: with_capacity ( 273108 ) ;
3431 let ser_handle: SerializableHandle = doc. document . clone ( ) . into ( ) ;
35- rc_serialize ( & mut out, & ser_handle, Default :: default ( ) )
36- . expect ( "serialization" ) ;
32+ rc_serialize ( & mut out, & ser_handle, Default :: default ( ) ) . expect ( "serialization" ) ;
3733 assert_eq ! ( out. len( ) , 272273 ) ;
3834 } ) ;
3935}
4036
4137#[ bench]
4238fn b01_round_trip_marked ( b : & mut Bencher ) {
4339 b. iter ( || {
44- let mut fin = sample_file ( "github-dekellum.html" )
45- . expect ( "sample_file" ) ;
40+ let mut fin = sample_file ( "github-dekellum.html" ) . expect ( "sample_file" ) ;
4641 let eh = EncodingHint :: shared_default ( enc:: UTF_8 ) ;
4742 let doc = parse_buffered ( eh, & mut fin) . expect ( "parse" ) ;
4843 let mut out = Vec :: with_capacity ( 273108 ) ;
@@ -54,8 +49,7 @@ fn b01_round_trip_marked(b: &mut Bencher) {
5449#[ bench]
5550fn b11_decode_eucjp_parse_marked ( b : & mut Bencher ) {
5651 b. iter ( || {
57- let mut fin = sample_file ( "matsunami_eucjp_meta.html" )
58- . expect ( "sample_file" ) ;
52+ let mut fin = sample_file ( "matsunami_eucjp_meta.html" ) . expect ( "sample_file" ) ;
5953 let eh = EncodingHint :: shared_default ( enc:: UTF_8 ) ;
6054 parse_buffered ( eh, & mut fin) . expect ( "parse" ) ;
6155 } ) ;
@@ -64,8 +58,7 @@ fn b11_decode_eucjp_parse_marked(b: &mut Bencher) {
6458#[ bench]
6559fn b12_decode_windows1251_parse_marked ( b : & mut Bencher ) {
6660 b. iter ( || {
67- let mut fin = sample_file ( "russez_windows1251_meta.html" )
68- . expect ( "sample_file" ) ;
61+ let mut fin = sample_file ( "russez_windows1251_meta.html" ) . expect ( "sample_file" ) ;
6962 let eh = EncodingHint :: shared_default ( enc:: UTF_8 ) ;
7063 parse_buffered ( eh, & mut fin) . expect ( "parse" ) ;
7164 } ) ;
@@ -74,17 +67,15 @@ fn b12_decode_windows1251_parse_marked(b: &mut Bencher) {
7467#[ bench]
7568fn b13_utf8_parse_marked ( b : & mut Bencher ) {
7669 b. iter ( || {
77- let mut fin = sample_file ( "github-dekellum.html" )
78- . expect ( "sample_file" ) ;
70+ let mut fin = sample_file ( "github-dekellum.html" ) . expect ( "sample_file" ) ;
7971 let eh = EncodingHint :: shared_default ( enc:: UTF_8 ) ;
8072 parse_buffered ( eh, & mut fin) . expect ( "parse" ) ;
8173 } ) ;
8274}
8375
8476#[ bench]
8577fn b20_text_content ( b : & mut Bencher ) {
86- let mut fin = sample_file ( "github-dekellum.html" )
87- . expect ( "sample_file" ) ;
78+ let mut fin = sample_file ( "github-dekellum.html" ) . expect ( "sample_file" ) ;
8879 let eh = EncodingHint :: shared_default ( enc:: UTF_8 ) ;
8980 let doc = parse_buffered ( eh, & mut fin) . expect ( "parse" ) ;
9081
@@ -96,8 +87,7 @@ fn b20_text_content(b: &mut Bencher) {
9687
9788#[ bench]
9889fn b30_text_normalize_content ( b : & mut Bencher ) {
99- let mut fin = sample_file ( "github-dekellum.html" )
100- . expect ( "sample_file" ) ;
90+ let mut fin = sample_file ( "github-dekellum.html" ) . expect ( "sample_file" ) ;
10191 let eh = EncodingHint :: shared_default ( enc:: UTF_8 ) ;
10292 let doc = parse_buffered ( eh, & mut fin) . expect ( "parse" ) ;
10393 b. iter ( || {
@@ -120,8 +110,7 @@ fn b30_text_normalize_content(b: &mut Bencher) {
120110
121111#[ bench]
122112fn b31_text_normalize_content_identity ( b : & mut Bencher ) {
123- let mut fin = sample_file ( "github-dekellum.html" )
124- . expect ( "sample_file" ) ;
113+ let mut fin = sample_file ( "github-dekellum.html" ) . expect ( "sample_file" ) ;
125114 let eh = EncodingHint :: shared_default ( enc:: UTF_8 ) ;
126115 let mut doc = parse_buffered ( eh, & mut fin) . expect ( "parse" ) ;
127116 doc. filter ( chain_filters ! (
0 commit comments