# 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
```bash
cargo install --path packages/bloaty
```
## Usage
Basic usage:
```bash
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
```bash
--package pkg1,pkg2,pkg3
--package pkg1 --package pkg2 --package pkg3
```
- `--skip-packages <SKIP_PACKAGES>`: Packages to skip
```bash
--skip-packages pkg1,pkg2
--skip-packages pkg1 --skip-packages pkg2
```
- `--skip-features <SKIP_FEATURES>`: Features to skip
```bash
--skip-features test,bench,dev
--skip-features test --skip-features bench
```
- `-t, --tool <TOOL>`: Tools to use (options: bloat, llvm-lines, size)
```bash
--tool bloat,size
--tool bloat --tool size
```
- `--report-file <REPORT_FILE>`: Custom report file name (without extension)
- `--output-format <FORMAT>`: Output format (text, json, jsonl, all)
```bash
--output-format text,json
--output-format text --output-format json
--output-format all
```
### Examples
Analyze specific packages:
```bash
# 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:
```bash
# 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:
```bash
# 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:
```bash
# 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:
```bash
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: 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:
```jsonl
{"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:
```bash
cargo install cargo-bloat cargo-llvm-lines cargo-size
```