| 103 | } |
| 104 | |
| 105 | fn bench_write_f64(c: &mut Criterion) { |
| 106 | let mut group = c.benchmark_group("write_f64"); |
| 107 | group.throughput(Throughput::Elements(1000)); |
| 108 | |
| 109 | let values: Vec<f64> = (0..1000).map(|i| i as f64 * 1.23456).collect(); |
| 110 | |
| 111 | group.bench_function("current", |b| { |
| 112 | let mut buf = Vec::with_capacity(8000); |
| 113 | b.iter(|| { |
| 114 | buf.clear(); |
| 115 | let mut writer = Writer::from_buffer(&mut buf); |
| 116 | for &val in &values { |
| 117 | writer.write_f64(black_box(val)); |
| 118 | } |
| 119 | black_box(&buf); |
| 120 | }) |
| 121 | }); |
| 122 | |
| 123 | group.finish(); |
| 124 | } |
| 125 | |
| 126 | fn bench_write_var_i32_small(c: &mut Criterion) { |
| 127 | let mut group = c.benchmark_group("write_var_i32_small"); |