summaryrefslogtreecommitdiff
path: root/crates/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'crates/benchmarks')
-rw-r--r--crates/benchmarks/benches/selfhosted.rs2
-rw-r--r--crates/benchmarks/benches/util/mod.rs5
2 files changed, 6 insertions, 1 deletions
diff --git a/crates/benchmarks/benches/selfhosted.rs b/crates/benchmarks/benches/selfhosted.rs
index 542343e..94dfdce 100644
--- a/crates/benchmarks/benches/selfhosted.rs
+++ b/crates/benchmarks/benches/selfhosted.rs
@@ -55,7 +55,7 @@ const TINYWASM: &[u8] = include_bytes!("../../../examples/rust/out/tinywasm.wasm
fn criterion_benchmark(c: &mut Criterion) {
{
let mut group = c.benchmark_group("selfhosted-parse");
- group.bench_function("tinywasm", |b| b.iter(|| util::wasm_to_twasm(TINYWASM)));
+ group.bench_function("tinywasm", |b| b.iter(|| util::parse_wasm(TINYWASM)));
}
{
diff --git a/crates/benchmarks/benches/util/mod.rs b/crates/benchmarks/benches/util/mod.rs
index d6594b9..0df2a52 100644
--- a/crates/benchmarks/benches/util/mod.rs
+++ b/crates/benchmarks/benches/util/mod.rs
@@ -2,6 +2,11 @@
use tinywasm::{self, parser::Parser, types::TinyWasmModule};
+pub fn parse_wasm(wasm: &[u8]) -> TinyWasmModule {
+ let parser = Parser::new();
+ parser.parse_module_bytes(wasm).expect("parse_module_bytes")
+}
+
pub fn wasm_to_twasm(wasm: &[u8]) -> Vec<u8> {
let parser = Parser::new();
let res = parser.parse_module_bytes(wasm).expect("parse_module_bytes");