| Crates.io | canbench-rs |
| lib.rs | canbench-rs |
| version | 0.4.0 |
| created_at | 2024-02-09 13:48:58.424739+00 |
| updated_at | 2025-11-21 15:21:13.331801+00 |
| description | The rust library for `canbench`, the benchmarking framework for canisters on the Internet Computer. |
| homepage | |
| repository | https://github.com/dfinity/canbench |
| max_upload_size | |
| id | 1133970 |
| size | 53,980 |
canbenchcanbench is a tool for benchmarking canisters on the Internet Computer.
Canister smart contracts on the Internet Computer consume compute and memory resources.
Since resources are finite, execution of a message (transaction) must remain within specific bounds:
If a message exceeds these limits, it is aborted.
canbench gives developers insights into how their code consumes instructions and memory.
Support for reporting dirty pages will be added once the IC exposes that information.
Relevant metrics
Traditional benchmarking tools rely on repeated runs and averaging time.
On the deterministic Internet Computer, this is neither necessary nor insightful.
canbench reports instruction count and memory changes directly.
Regression detection
Persist benchmark results in your repo.
canbench compares results over time to highlight performance regressions.
High instruction limits
While regular messages are capped at a few billion instructions, canbench supports up to 10 trillion, allowing deep benchmarking.
Language-agnostic
While currently Rust-focused, canbench is designed to support canisters written in any language.
cargo install canbench
See the crate's documentation.
You can integrate canbench into your GitHub CI pipeline to catch regressions automatically.
You’ll need:
Benchmark scripts (see scripts/ directory)
A workflow that posts benchmarking results as PR comments (canbench-post-comment.yml)
A job to upload the PR number (see upload-pr-number in ci.yml)
The benchmark job itself (e.g. benchmark-fibonacci-example in ci.yml)
Once configured, the job will fail on regressions and pass otherwise. It will also leave a PR comment with detailed results. See this PR example.