| Crates.io | cargo-samply |
| lib.rs | cargo-samply |
| version | 0.3.2 |
| created_at | 2023-12-09 13:08:15.003224+00 |
| updated_at | 2025-09-03 13:53:21.724636+00 |
| description | A cargo subcommand to automate the process of running samply for project binaries |
| homepage | https://github.com/PhilippPolterauer/cargo-samply.git |
| repository | https://github.com/PhilippPolterauer/cargo-samply.git |
| max_upload_size | |
| id | 1063679 |
| size | 141,317 |
A cargo subcommand to automate the process of running cargo build with a certain profile and samply afterwards.
This tool simplifies profiling Rust applications by managing build profiles and coordinating with the samply profiler.
You can install it from crates.io or directly from github.com:
# Install cargo-samply
cargo install cargo-samply
# Install samply (required dependency)
cargo install samply
Or install from git:
cargo install --git https://github.com/PhilippPolterauer/cargo-samply.git
Note: You must have samply installed and available in your PATH for profiling to work.
$ cargo samply --help
The samply subcommand
Usage: cargo samply [OPTIONS] [TRAILING_ARGUMENTS]...
Arguments:
[TRAILING_ARGUMENTS]... Trailing arguments passed to the binary being profiled
Options:
-p, --profile <PROFILE> Build with the specified profile [default: samply]
-b, --bin <BIN> Binary to run
-e, --example <EXAMPLE> Example to run
-f, --features <FEATURES> Build features to enable
--no-default-features Disable default features
-v, --verbose Print extra output to help debug problems
-q, --quiet Suppress all output except errors
-n, --no-samply Disable the automatic samply start
-h, --help Print help
-V, --version Print version
A minimal example on how to use cargo-samply.
$ cargo install cargo-samply
$ cargo new mybinary
Created binary (application) `mybinary` package
$ cd mybinary
$ cargo samply
When opening the server address (127.0.0.1:3001) the output should look like the following:

# Profile a specific binary
cargo samply --bin my-binary
# Profile an example
cargo samply --example my-example
# Use a different profile
cargo samply --profile release
# Enable specific features
cargo samply --features feature1,feature2
# Run with verbose output
cargo samply --verbose
# Just run the binary without profiling
cargo samply --no-samply
# Pass arguments to the binary
cargo samply -- arg1 arg2 --flag value
This project includes a justfile for common development tasks. Install just and use:
# Run tests (matches CI configuration)
just test
# Update test snapshots when needed
just test-overwrite
# Clean all target directories
just clean-all
# Clean only test project target directories
just clean
# Clean only main project
just clean-main
The project uses trycmd for integration testing, which validates CLI behavior against snapshot files.
When making changes that affect command output:
just test to see if tests passjust test-overwrite to update snapshotsjust test to ensure tests pass