Awesome Sails Benchmarks
Note: Built for the Sails framework. It is highly recommended to study the Sails Documentation before using this crate.
A benchmarking suite for Sails programs. This crate provides tools to measure gas consumption and a CLI utility to analyze performance regressions.
Features
gtest(default): Enables built-in support for the Geargtestframework and provides theMeasureGasimplementation forSystem.ascii-table: Enables ASCII table output for terminal reports.cli: Enables thebench-analyzerCLI utility.
Installation
Add to your Cargo.toml:
[]
# Standard usage (with gtest support)
= { = "x.y.z", = ["ascii-table"] }
# If you have version conflicts with gtest, disable default features:
= { = "x.y.z", = false }
Usage
1. Gas Measurement
Use the MeasureGas trait to capture gas during tests. Benchmarks MUST be run in --release mode.
The MeasureGas trait is always available, but the implementation for the Gear gtest::System requires the gtest feature (enabled by default).
use ;
use BTreeMap;
async
2. Analysis
The bench-analyzer utility compares generated results with a baseline.
Installation
Install the tool globally via cargo:
Comparison Modes
- Regression Check (Default): Fails if any metric increases beyond the
--threshold. - Strict Mode (
--strict): Fails if any metric deviates (increases OR decreases) by more than the threshold. Useful for ensuring benchmark stability.
Usage
CLI Reference
A CLI tool to compare two benchmark JSON files and detect performance regressions.
Usage: bench-analyzer [OPTIONS] --current <CURRENT> --other <OTHER>
Options:
--current <CURRENT> Path to the current benchmark results
--other <OTHER> Path to the baseline benchmark results
--output <OUTPUT> Path to save the comparison report in Markdown format
--threshold <THRESHOLD> Custom regression threshold percentage (e.g. 5.0)
--strict Enable strict mode: fail if ANY metric deviates from baseline
-h, --help Print help