Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E. Performance

These numbers come from cargo bench -p airsl on one machine. Treat them as a rough guide to the relative cost of things, not as a guarantee, and measure on your own hardware before relying on them.

Inside a Rust program

WhatWith limitsWithout limits
Building an engine128 µs102 µs
Running a trivial script on an existing engine4.6 µs3.4 µs
Running a script that makes 1000 module calls1073 µs955 µs
Building an engine and running a trivial script136 µs100 µs

Two things stand out.

Reusing an engine is about thirty times faster than building one. That is why chapter 6 recommends keeping an engine for scripts that trust each other.

The limits cost about a quarter of a small script's running time. The instruction limit has to be checked as the script runs. That is the price of being able to stop a script that never ends. You can turn the limits off, but make it a decision rather than a default.

From the command line

CommandTime per run
airsl run on a trivial script3.2 ms
python3 -c 'print("hi")'13.8 ms
sh -c 'echo hi'2.2 ms

Starting a process takes far longer than anything in the first table, so for the command line none of those costs matter. airsl starts about four times faster than Python, and within half again of a bare shell.