Projects Publications Resume Contact About Youtube |
|
perf.rs |
use std::env; fn main() { let iterations: usize; let mut sum: f64 = 0.0; let array_length: usize = 100000000; let args: Vec< String > = env::args().collect(); let mut array: Vec< f64 > = vec![0.0; array_length]; iterations = (&args[1]).parse().expect("Not a number"); println!("iterations {}", iterations); for element in 0..array_length { array[element] = element as f64; } for iteration in 0..iterations { for innerloop in 0..1000000000 { sum += array[(iteration + innerloop) % array_length]; } } println!("sum {}", sum); } |
all: \ perf-rust \ perf-rust.wasm \ mem-rust \ mem-rust.wasm \ perf-rust: perf.rs rustc -C opt-level=3 -o perf-rust perf.rs perf-rust.wasm: perf.rs rustc --target=wasm32-wasi -C opt-level=3 -o perf-rust.wasm perf.rs mem-rust: mem.rs rustc -C opt-level=3 -o mem-rust mem.rs mem-rust.wasm: mem.rs rustc --target=wasm32-wasi -C opt-level=3 -o mem-rust.wasm mem.rs clean: rm -f *.o *.so rm -f perf-rust rm -f perf-rust.wasm rm -f mem-rust rm -f mem-rust.wasm run_perf_test: all echo "-------------------------------------" time -p ./perf-rust 100 time -p wasmtime perf-rust.wasm 100 echo "-------------------------------------" run_mem_test: all echo "-------------------------------------" ./capture.sh mem-rust & ./mem-rust ; sleep 2 ./capture.sh mem-rust.wasm & wasmtime mem-rust.wasm ; sleep 2 echo "-------------------------------------"