File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,18 @@ fn do_encode_bench_stream(b: &mut Bencher, &size: &usize) {
123123 } ) ;
124124}
125125
126+ fn do_encode_bench_string_stream ( b : & mut Bencher , & size: & usize ) {
127+ let mut v: Vec < u8 > = Vec :: with_capacity ( size) ;
128+ fill ( & mut v) ;
129+
130+ b. iter ( || {
131+ let mut stream_enc = write:: EncoderStringWriter :: new ( TEST_CONFIG ) ;
132+ stream_enc. write_all ( & v) . unwrap ( ) ;
133+ stream_enc. flush ( ) . unwrap ( ) ;
134+ let _ = stream_enc. finish ( ) . unwrap ( ) ;
135+ } ) ;
136+ }
137+
126138fn fill ( v : & mut Vec < u8 > ) {
127139 let cap = v. capacity ( ) ;
128140 // weak randomness is plenty; we just want to not be completely friendly to the branch predictor
@@ -147,6 +159,7 @@ fn encode_benchmarks(byte_sizes: &[usize]) -> ParameterizedBenchmark<usize> {
147159 . with_function ( "encode_reuse_buf" , do_encode_bench_reuse_buf)
148160 . with_function ( "encode_slice" , do_encode_bench_slice)
149161 . with_function ( "encode_reuse_buf_stream" , do_encode_bench_stream)
162+ . with_function ( "encode_string_stream" , do_encode_bench_string_stream)
150163}
151164
152165fn decode_benchmarks ( byte_sizes : & [ usize ] ) -> ParameterizedBenchmark < usize > {
You can’t perform that action at this time.
0 commit comments