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

Function criterion_benchmark

crates/tinywasm/benches/memory_backends.rs:73–149  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

71}
72
73fn criterion_benchmark(c: &mut Criterion) {
74 let mut group = c.benchmark_group("memory_backends");
75 group.measurement_time(BENCH_MEASUREMENT_TIME);
76
77 bench_grow(&mut group, "vec", || VecMemory::try_new(PAGE_SIZE).expect("bench memory should be constructible"));
78 bench_grow(&mut group, "paged", || {
79 PagedMemory::try_new(PAGE_SIZE, CHUNK_SIZE).expect("bench memory should be constructible")
80 });
81
82 bench_write_all(
83 &mut group,
84 "vec",
85 "contiguous",
86 VecMemory::try_new(MEMORY_LEN).expect("bench memory should be constructible"),
87 CONTIGUOUS_OFFSET,
88 CONTIGUOUS_LEN,
89 );
90 bench_write_all(
91 &mut group,
92 "paged",
93 "contiguous",
94 PagedMemory::try_new(MEMORY_LEN, CHUNK_SIZE).expect("bench memory should be constructible"),
95 CONTIGUOUS_OFFSET,
96 CONTIGUOUS_LEN,
97 );
98 bench_read_exact(
99 &mut group,
100 "vec",
101 "contiguous",
102 VecMemory::try_new(MEMORY_LEN).expect("bench memory should be constructible"),
103 CONTIGUOUS_OFFSET,
104 CONTIGUOUS_LEN,
105 );
106 bench_read_exact(
107 &mut group,
108 "paged",
109 "contiguous",
110 PagedMemory::try_new(MEMORY_LEN, CHUNK_SIZE).expect("bench memory should be constructible"),
111 CONTIGUOUS_OFFSET,
112 CONTIGUOUS_LEN,
113 );
114
115 bench_write_all(
116 &mut group,
117 "vec",
118 "cross_chunk",
119 VecMemory::try_new(MEMORY_LEN).expect("bench memory should be constructible"),
120 CROSS_CHUNK_OFFSET,
121 CROSS_CHUNK_LEN,
122 );
123 bench_write_all(
124 &mut group,
125 "paged",
126 "cross_chunk",
127 PagedMemory::try_new(MEMORY_LEN, CHUNK_SIZE).expect("bench memory should be constructible"),
128 CROSS_CHUNK_OFFSET,
129 CROSS_CHUNK_LEN,
130 );

Callers

nothing calls this directly

Calls 4

bench_growFunction · 0.85
bench_write_allFunction · 0.85
bench_read_exactFunction · 0.85
finishMethod · 0.80

Tested by

no test coverage detected