diff options
| author | Micha White <botahamec@outlook.com> | 2023-11-12 21:36:20 -0500 |
|---|---|---|
| committer | Micha White <botahamec@outlook.com> | 2023-11-12 21:36:20 -0500 |
| commit | 82a737798b5694e353971a00f46d117743d2a03e (patch) | |
| tree | 0a7ad7cd5e855ac33eb727380453cee21255ecb0 | |
| parent | ec1f71ad69e9a286f6c68f51b3a3ec2a02dd14bb (diff) | |
Create a benchmark for scripts
| -rw-r--r-- | scripts/bin/benchmark.rs | 16 | ||||
| -rw-r--r-- | scripts/bin/ex.wat | 29 |
2 files changed, 45 insertions, 0 deletions
diff --git a/scripts/bin/benchmark.rs b/scripts/bin/benchmark.rs new file mode 100644 index 0000000..24f672d --- /dev/null +++ b/scripts/bin/benchmark.rs @@ -0,0 +1,16 @@ +use std::time::Instant; + +use scripts::ScriptManager; + +fn main() { + let mut manager = ScriptManager::new(); + let start = Instant::now(); + manager + .add_wasm_script(Box::from("example"), "bin/ex.wat", false) + .unwrap(); + println!("Took {} microseconds", start.elapsed().as_micros()); + + let start = Instant::now(); + manager.run_update_scripts(); + println!("Took {} microseconds", start.elapsed().as_micros()); +} diff --git a/scripts/bin/ex.wat b/scripts/bin/ex.wat new file mode 100644 index 0000000..af461bd --- /dev/null +++ b/scripts/bin/ex.wat @@ -0,0 +1,29 @@ +(module + (import "alligator" "abs" (func $abs (param i32) (result i32))) + (func $add1 + (local $i i32) + (loop $myloop + local.get $i + i32.const 1 + i32.add + local.set $i + + local.get $i + call $abs + + local.get $i + i32.const 40 + i32.lt_s + br_if $myloop + + drop + ) + ) + (func $add2 nop) + (export "begin" (func $add2)) + (export "update" (func $add1)) + (memory (;0;) 16) + (export "memory" (memory 0)) + (global $base i32 (i32.const 1)) + (export "__heap_base" (global $base)) +) |
