2 releases
Uses new Rust 2024
new 0.0.2 | May 22, 2025 |
---|---|
0.0.1 | May 22, 2025 |
#1 in #jsonl
23KB
482 lines
Bloaty
A tool for analyzing binary size and feature impact across Rust workspace members. Bloaty helps you understand how different features affect your binary sizes and identify potential optimization opportunities.
Features
- Analyze binary sizes across workspace members
- Compare feature impact on binary sizes
- Support for multiple output formats (text, JSON, JSONL)
- Integration with cargo-bloat, cargo-llvm-lines, and cargo-size
- Detailed reporting of size differences between features
Installation
cargo install --path packages/bloaty
Usage
Basic usage:
cargo run --bin bloaty
This will analyze all workspace members and generate reports in all supported formats.
Command Line Options
All list arguments (packages, skip-packages, skip-features, tool, output-format) support both comma-separated lists and multiple arguments.
-
-p, --package <PACKAGE>
: Specify packages to analyze# Using comma-separated list --package pkg1,pkg2,pkg3 # Using multiple arguments --package pkg1 --package pkg2 --package pkg3
-
--skip-packages <SKIP_PACKAGES>
: Packages to skip# Using comma-separated list --skip-packages pkg1,pkg2 # Using multiple arguments --skip-packages pkg1 --skip-packages pkg2
-
--skip-features <SKIP_FEATURES>
: Features to skip# Using comma-separated list --skip-features test,bench,dev # Using multiple arguments --skip-features test --skip-features bench
-
-t, --tool <TOOL>
: Tools to use (options: bloat, llvm-lines, size)# Using comma-separated list --tool bloat,size # Using multiple arguments --tool bloat --tool size
-
--report-file <REPORT_FILE>
: Custom report file name (without extension) -
--output-format <FORMAT>
: Output format (text, json, jsonl, all)# Using comma-separated list --output-format text,json # Using multiple arguments --output-format text --output-format json # Using 'all' for all formats --output-format all
Examples
Analyze specific packages:
# Using comma-separated list
cargo run --bin bloaty -- -p package1,package2
# Using multiple arguments
cargo run --bin bloaty -- -p package1 -p package2
Skip certain features:
# Using comma-separated list
cargo run --bin bloaty -- --skip-features test,bench,dev
# Using multiple arguments
cargo run --bin bloaty -- --skip-features test --skip-features bench
Use specific tools:
# Using comma-separated list
cargo run --bin bloaty -- -t bloat,size
# Using multiple arguments
cargo run --bin bloaty -- -t bloat -t size
Generate specific output formats:
# Using comma-separated list
cargo run --bin bloaty -- --output-format text,json
# Using multiple arguments
cargo run --bin bloaty -- --output-format text --output-format json
# Generate all formats
cargo run --bin bloaty -- --output-format all
Custom report file:
cargo run --bin bloaty -- --report-file analysis
Output Formats
Text Format
Human-readable format showing package, target, and feature sizes with differences.
Example:
Package: my_crate
===================
Target: my_target
-------------------
Base size: 1.2 MB
Feature: default | Size: 1.2 MB | Diff: +0 B
Feature: extra | Size: 1.5 MB | Diff: +300 KB
Feature: minimal | Size: 900 KB | Diff: -300 KB
JSON Format
Complete analysis in a single JSON object, useful for programmatic processing.
JSONL Format
Line-delimited JSON format, with each line representing a single event in the analysis process. Useful for streaming and real-time processing.
Example:
{"type":"package_start","name":"my_crate","timestamp":1234567890}
{"type":"target_start","package":"my_crate","target":"my_target","timestamp":1234567890}
{"type":"base_size","package":"my_crate","target":"my_target","size":1258291,"size_formatted":"1.2 MB","timestamp":1234567890}
{"type":"feature","package":"my_crate","target":"my_target","feature":"default","size":1258291,"diff":0,"diff_formatted":"+0 B","size_formatted":"1.2 MB","timestamp":1234567890}
Dependencies
- cargo-bloat
- cargo-llvm-lines
- cargo-size
Make sure these tools are installed before running bloaty:
cargo install cargo-bloat cargo-llvm-lines cargo-size
Dependencies
~2–3MB
~57K SLoC