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 home page measures mimas against the other pure-Rust scripting runtimes. Here we’ll narrow down with the intention of showing the most likely alternative options one would use against mimas.
Rune and Rhai are the pure-Rust points of comparison: Rune is the quickest of them after mimas, and Rhai is feature-rich and by far the most widely used in the space. Luau (through mlua) is is the quickest thing you can embed in a Rust program, full stop. However, unlike the others, it is written in C++.
strings string formatting, builtin methods
| mimas | 435ms |
|---|---|
| luau | 599ms |
| rune | 1.70s |
| rhai | 3.46s |
physics struct field access, float math
| luau | 738ms |
|---|---|
| mimas | 928ms |
| rune | 2.81s |
| rhai | 12.68s |
mandelbrot scalar float throughput, tight loops
| luau | 291ms |
|---|---|
| mimas | 744ms |
| rune | 1.40s |
| rhai | 7.56s |
prime numbers array indexing, tight integer loops
| luau | 485ms |
|---|---|
| mimas | 597ms |
| rune | 2.13s |
| rhai | 4.82s |
fibonacci function-call overhead, recursion
| luau | 384ms |
|---|---|
| mimas | 1.17s |
| rune | 1.41s |
| rhai | 5.87s |
eval enum match dispatch, recursion
| luau | 634ms |
|---|---|
| mimas | 1.29s |
| rune | 1.30s |
| rhai | 38.82s |
collections dict insert + lookup, string keys
| luau | 229ms |
|---|---|
| mimas | 366ms |
| rune | 1.81s |
| rhai | 2.85s |
mimas v0.1.0 · Rune v0.14.2 · Rhai (perf) v1.26.0 · Luau (mlua) v0.11.4 -- measured on an AMD Ryzen 7 9800X3D running Linux. 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 compilation using something like Cranelift. A JIT has to write fresh machine code into memory at runtime, 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.
Pulley remains an option that could improve performance further, which will be later explored.
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 | ~16 ms |
| a large project | ~100,000 | ~0.20 s |
Measured with `mimas build` on the same machine, 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 (which needs hyperfine), and the compile-speed table with benchmarks/compile-bench.sh. cargo bench -p mimas runs our own benchmarks through criterion.