MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / bench_read_exact

Function bench_read_exact

crates/tinywasm/benches/memory_backends.rs:53–71  ·  view source on GitHub ↗
(
    group: &mut BenchmarkGroup<'_, WallTime>,
    backend: &str,
    workload: &str,
    mut memory: M,
    offset: usize,
    len: usize,
)

Source from the content-addressed store, hash-verified

51}
52
53fn bench_read_exact<M: LinearMemory>(
54 group: &mut BenchmarkGroup<'_, WallTime>,
55 backend: &str,
56 workload: &str,
57 mut memory: M,
58 offset: usize,
59 len: usize,
60) {
61 let src = vec![0x5A; len];
62 memory.write_all(offset, &src).unwrap();
63
64 let mut dst = vec![0; len];
65 group.bench_function(BenchmarkId::new(format!("read_exact/{workload}"), backend), |b| {
66 b.iter(|| {
67 memory.read_exact(offset, black_box(&mut dst)).unwrap();
68 black_box(&dst);
69 })
70 });
71}
72
73fn criterion_benchmark(c: &mut Criterion) {
74 let mut group = c.benchmark_group("memory_backends");

Callers 1

criterion_benchmarkFunction · 0.85

Calls 2

write_allMethod · 0.45
read_exactMethod · 0.45

Tested by

no test coverage detected