MCPcopy Create free account
hub / github.com/apache/fory / bench_write_f32

Function bench_write_f32

benchmarks/rust/benches/buffer_write_bench.rs:84–103  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

82}
83
84fn 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
105fn bench_write_f64(c: &mut Criterion) {
106 let mut group = c.benchmark_group("write_f64");

Callers

nothing calls this directly

Calls 4

write_f32Method · 0.80
mapMethod · 0.45
clearMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected