Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jedrzejboczar/rust-type-sizes
Generate HTML report with type sizes of a Rust program
https://github.com/jedrzejboczar/rust-type-sizes
Last synced: about 2 months ago
JSON representation
Generate HTML report with type sizes of a Rust program
- Host: GitHub
- URL: https://github.com/jedrzejboczar/rust-type-sizes
- Owner: jedrzejboczar
- Created: 2022-07-22T14:14:10.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-16T19:34:56.000Z (about 2 years ago)
- Last Synced: 2023-03-05T12:05:28.638Z (almost 2 years ago)
- Language: Python
- Size: 266 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rust-type-sizes
A script to analyze type sizes used in a Rust program.
It first compiles the code with `cargo +nightly rustc -- -Zprint-type-sizes`
(requires nightly toolchain) and then generates a HTML report.
The report is organized into collapsible tree of types/fields/variants
with information about their size, alignment and offset (fields).## Usage
Make sure to download nightly version of the toolchain used in the project,
e.g. when building for host on linux:```sh
rustup target add x86_64-unknown-linux-gnu --toolchain nightly
```e.g. if cross-compiling for arm-unknown-linux-gnueabihf:
```sh
rustup target add arm-unknown-linux-gnueabihf --toolchain nightly
```Then enter Rust project directory and run:
```sh
python path/to/type-sizes.py --sort-size --bin your_binary_name --release
```Then open the file `./type-sizes/index.html` in web browser.
Use `python path/to/type-sizes.py` to see available options.
All unlisted arguments are passed to `cargo +nightly rustc -- -Zprint-type-sizes`.## Example output
![Example HTML output](./media/html_report_example.png)