| 82 | } |
| 83 | |
| 84 | fn bench_write_f32(c: &mut Criterion) { |
| 85 | let mut group = c.benchmark_group("write_f32"); |
| 86 | group.throughput(Throughput::Elements(1000)); |
| 87 | |
| 88 | let values: Vec<f32> = (0..1000).map(|i| i as f32 * 1.23).collect(); |
| 89 | |
| 90 | group.bench_function("current", |b| { |
| 91 | let mut buf = Vec::with_capacity(4000); |
| 92 | b.iter(|| { |
| 93 | buf.clear(); |
| 94 | let mut writer = Writer::from_buffer(&mut buf); |
| 95 | for &val in &values { |
| 96 | writer.write_f32(black_box(val)); |
| 97 | } |
| 98 | black_box(&buf); |
| 99 | }) |
| 100 | }); |
| 101 | |
| 102 | group.finish(); |
| 103 | } |
| 104 | |
| 105 | fn bench_write_f64(c: &mut Criterion) { |
| 106 | let mut group = c.benchmark_group("write_f64"); |