| Crates.io | cargo-size |
| lib.rs | cargo-size |
| version | 0.1.1 |
| created_at | 2025-10-18 12:43:50.334053+00 |
| updated_at | 2025-10-18 12:51:20.453336+00 |
| description | Tool to check and compare binary sizes of Rust projects |
| homepage | https://github.com/abhinav-1305/cargo-size |
| repository | https://github.com/abhinav-1305/cargo-size |
| max_upload_size | |
| id | 1889177 |
| size | 97,022 |
Tool to check and compare binary sizes of Rust projects. Interact with Cargo APIs to analyze and track binary size changes over time.
cargo install cargo-size
Or build from source:
git clone https://github.com/yourusername/cargo-size
cd cargo-size
cargo build --release
Check the size of a specific package or all packages in the workspace:
# Check current package size (debug build)
cargo size
# Check specific package
cargo size check --package my-package
# Check release build
cargo size check --release
# Check with specific target
cargo size check --target x86_64-unknown-linux-gnu
Compare sizes between different packages or builds:
# Compare two packages
cargo size compare --packages package-a package-b
# Compare with specific baseline
cargo size compare --packages package-a package-b --baseline package-a
# Compare release builds
cargo size compare --packages package-a package-b --release
Track size changes over time:
# View size history for current package
cargo size history
# View history for specific package
cargo size history --package my-package
# Limit history entries
cargo size history --limit 20
Choose from different output formats:
# Table format (default)
cargo size check
# JSON format
cargo size check --output-format json
# CSV format
cargo size check --output-format csv
$ cargo size check
┌─────────────┬──────────────┬─────────┬────────────┬─────────┬─────────────────────┐
│ Package │ Binary │ Size │ Build Type │ Target │ Timestamp │
├─────────────┼──────────────┼─────────┼────────────┼─────────┼─────────────────────┤
│ my-app │ my-app │ 2.45 MB │ debug │ host │ 2024-01-15 10:30:45 │
└─────────────┴──────────────┴─────────┴────────────┴─────────┴─────────────────────┘
$ cargo size compare --packages old-version new-version --release
┌─────────────┬─────────┬──────────────┬────────────┬───────────┬────────────┐
│ Package │ Size │ vs Baseline │ Difference │ Change % │ Build Type │
├─────────────┼─────────┼──────────────┼────────────┼───────────┼────────────┤
│ new-version │ 1.2 MB │ 1.0 MB │ +200 KB │ 🔴+20.00% │ release │
└─────────────┴─────────┴──────────────┴────────────┴───────────┴────────────┘
$ cargo size check --output-format json
[
{
"package_name": "my-app",
"binary_name": "my-app",
"size": 2568192,
"size_formatted": "2.45 MB",
"build_type": "debug",
"target": "host",
"timestamp": "2024-01-15T10:30:45.123Z"
}
]
--output-format <FORMAT>: Output format (table, json, csv)checkCheck the size of packages.
--package <NAME>: Package name to check--manifest-path <PATH>: Path to Cargo.toml--release: Check release build instead of debug--target <TRIPLE>: Target triple to build forcompareCompare sizes between packages or builds.
--packages <NAMES>...: Package names to compare--manifest-path <PATH>: Path to Cargo.toml--release: Compare release builds--target <TRIPLE>: Target triple to build for--baseline <NAME>: Use specific package as baselinehistoryShow size history for a package.
--package <NAME>: Package name to check history for--manifest-path <PATH>: Path to Cargo.toml--target <TRIPLE>: Target triple to build for--limit <NUMBER>: Limit number of history entries (default: 10)You can integrate cargo-size into your CI/CD pipeline to track binary size changes:
# GitHub Actions example
- name: Check binary size
run: |
cargo size check --release --output-format json > size-report.json
# Compare with baseline or fail if size increase is too large
Contributions are welcome! Please feel free to submit a Pull Request.
cargo buildcargo testcargo run -- checkThis project is licensed under either of
at your option.
Inspired by the webbrowser crate's approach to consistent behavior across platforms and comprehensive documentation.