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

Function bench_grow

crates/tinywasm/benches/memory_backends.rs:17–34  ·  view source on GitHub ↗
(group: &mut BenchmarkGroup<'_, WallTime>, backend: &str, make_memory: F)

Source from the content-addressed store, hash-verified

15const CROSS_CHUNK_LEN: usize = CHUNK_SIZE * 2;
16
17fn bench_grow<M, F>(group: &mut BenchmarkGroup<'_, WallTime>, backend: &str, make_memory: F)
18where
19 M: LinearMemory,
20 F: Fn() -> M + Copy,
21{
22 group.bench_function(BenchmarkId::new("grow", backend), |b| {
23 b.iter_batched(
24 make_memory,
25 |mut memory| {
26 for page_count in 2..=GROW_STEPS + 1 {
27 memory.grow_to(page_count * PAGE_SIZE).unwrap();
28 }
29 black_box(memory.len())
30 },
31 BatchSize::SmallInput,
32 )
33 });
34}
35
36fn bench_write_all<M: LinearMemory>(
37 group: &mut BenchmarkGroup<'_, WallTime>,

Callers 1

criterion_benchmarkFunction · 0.85

Calls 2

grow_toMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected