Benchmarks
The core ethos of mimas is flexibility with safety. The upshot of the latter is a plethora of guarantees for the compiler and runtime, allowing it to optimize the bytecode very tightly.
The wider ecosystem of scripting options can be viewed against mimas on the home page. Here, we’ll narrow down to a few. Luau (through mlua) is the fastest option you can embed in Rust, though it’s a C++ runtime rather than a Rust one. Rune, like mimas, is written in pure Rust, and is the fastest of our options in that category. Rhai, another pure-Rust option, is feature-rich and the most popular in the space.
strings string formatting, builtin methods
| mimas | 656ms |
|---|---|
| luau | 869ms |
| rune | 3.34s |
| rhai | 4.52s |
physics struct field access, float math
| mimas | 1.06s |
|---|---|
| luau | 1.15s |
| rune | 3.51s |
| rhai | 14.44s |
mandelbrot scalar float throughput, tight loops
| luau | 641ms |
|---|---|
| mimas | 940ms |
| rune | 1.52s |
| rhai | 7.20s |
prime numbers array indexing, tight integer loops
| luau | 544ms |
|---|---|
| mimas | 620ms |
| rune | 3.55s |
| rhai | 6.10s |
fibonacci function-call overhead, recursion
| luau | 737ms |
|---|---|
| mimas | 951ms |
| rune | 1.94s |
| rhai | 8.77s |
eval enum match dispatch, recursion
| luau | 622ms |
|---|---|
| mimas | 1.28s |
| rune | 1.88s |
| rhai | 70.73s |
collections dict insert + lookup, string keys
| luau | 360ms |
|---|---|
| mimas | 417ms |
| rune | 3.08s |
| rhai | 15.03s |
mimas v0.1.0 · Rune v0.14.2 · Rhai (perf) v1.25.1 · Luau (mlua) v0.11.4 -- measured on a 2021 MacBook Pro M1 Max. Bars are scaled within each test. Results slower than 5x of the fastest result are faded and not factored into the scaling.
What is idiomatic in one language very well may not match another, but these tests are written to be as structurally similar as possible – the same approach taken by Are We Fast Yet?, which compares languages on equivalent code rather than language-specific tricks. The intention is to measure how the same practices perform in each language. They therefore measure the cost of the abstraction, not raw arithmetic throughput: read them as “what does modelling your data this way cost?”, not “which language computes faster”.
The next step down from mimas’s current bytecode VM would be JIT using something like Cranelift. The problem is that JIT has to write fresh machine code into memory, and many of the platforms mimas cares about forbid exactly that. Game consoles (PlayStation, Xbox, Switch) disallow runtime-generated executable memory as a hard certification requirement; Apple’s platforms (iOS and its siblings) disallow it for third-party apps; sandboxes like the browser don’t offer it either.
This doesn’t mean that JIT (or anything beyond) is completely out of the question, but it would always exist as an optional feature, and likely won’t be a priority for a while.
Compile speed
The compiler is fast enough that you effectively won’t notice any compile times, running at about 400,000 lines per second. More timing information below.
| program | lines | compile |
|---|---|---|
| a small module | ~100 | < 1 ms |
| a project | ~10,000 | ~23 ms |
| a large project | ~100,000 | ~0.24 s |
Measured with `mimas build` on the same M1 Max, over a representative collection of source (consts, structs, enums, functions, deeply-nested types) generated by the fodder project (`tools/fodder`).
Reproduce
You can calculate these tests on your own machine with benchmarks/compare.sh, or with cargo bench -p mimas to run our benchmarks through criterion.