diff --git a/.gitignore b/.gitignore index 1c04bd5..d99755f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/flamegraph.svg /luac.out +/perf.data* /target /untracked diff --git a/Cargo.toml b/Cargo.toml index 8ead428..62cc3b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,12 @@ edition = "2021" # blake3, used to hash test vectors blake3 = "1.5.0" + +[target.x86_64-unknown-linux-gnu] +linker = "/usr/bin/clang" +# Recommended for flamegraph +rustflags = ["-Clink-arg=-fuse-ld=lld", "-Clink-arg=-Wl,--no-rosegment"] + +[profile.release] +# Recommended for profiling, e.g. flamegraph +debug = true diff --git a/README.md b/README.md index 117a989..6ed8ba2 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,33 @@ - [ ] Long strings - [ ] Using arrays internally for tables - [ ] Compiling Lua source code to bytecode + +# Benchmark + +9x slower than PUC Lua, 90x slower than LuaJIT. + +Based only on the n-body simulation from the computer language benchmarks, +because it's easy to run. + +``` +time target/release/lunar_wave_vm --script test_vectors/n_body.lua -- 500000; time lua test_vectors/n_body.lua 500000; time luajit test_vectors/n_body.lua 500000; +-0.169075164 +-0.169096567 +[src/main.rs:110] x = [] + +real 0m10.543s +user 0m10.535s +sys 0m0.000s +-0.169075164 +-0.169096567 + +real 0m1.173s +user 0m1.165s +sys 0m0.004s +-0.169075164 +-0.169096567 + +real 0m0.117s +user 0m0.116s +sys 0m0.000s +```