mirror of
https://github.com/Noratrieb/my-binary-is-thicc-af.git
synced 2026-01-14 19:55:07 +01:00
run instruction
This commit is contained in:
parent
321af3e846
commit
c50057a145
2 changed files with 18 additions and 1 deletions
11
README.md
Normal file
11
README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Rust binary size analyzer
|
||||
|
||||
How to use:
|
||||
|
||||
`cd client && npm i && npm run dev`
|
||||
|
||||
In a separate shell:
|
||||
|
||||
`cargo run --release BINARY_PATH > client/groups.json`
|
||||
|
||||
Note: The symbol parsing code is extremely cursed. This may lead to very wonky results.
|
||||
|
|
@ -17,6 +17,8 @@ fn main() -> Result<()> {
|
|||
.nth(1)
|
||||
.unwrap_or("./target/debug/my-binary-is-thicc-af".into());
|
||||
|
||||
let limit = 10;
|
||||
|
||||
let data = std::fs::read(&path).wrap_err_with(|| format!("error opening `{path}`"))?;
|
||||
let object = object::File::parse(data.as_slice()).context("could not parse object file")?;
|
||||
|
||||
|
|
@ -54,7 +56,11 @@ fn main() -> Result<()> {
|
|||
let mut root_groups = Groups(HashMap::new());
|
||||
|
||||
for (sym, size) in symbol_sizes {
|
||||
let components = symbol_components(sym).with_context(|| sym.to_string())?;
|
||||
let mut components = symbol_components(sym).with_context(|| sym.to_string())?;
|
||||
|
||||
if components.len() > limit {
|
||||
components.truncate(limit);
|
||||
}
|
||||
|
||||
add_to_group(&mut root_groups, components, size);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue