mirror of
https://github.com/Noratrieb/elven-forest.git
synced 2026-01-14 10:45:03 +01:00
yeah
This commit is contained in:
parent
40af8cd09f
commit
b4b14d376d
2 changed files with 36 additions and 10 deletions
17
elven-forest/size-analyze.py
Normal file
17
elven-forest/size-analyze.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import pandas as pd
|
||||||
|
import sys
|
||||||
|
import plotly.express as px
|
||||||
|
|
||||||
|
df = pd.read_csv(sys.argv[1])
|
||||||
|
#df = df[df['1'] == "rustc_middle[8d82ae2353292c40]"]
|
||||||
|
|
||||||
|
print(df)
|
||||||
|
|
||||||
|
fig = px.treemap(df, path=[px.Constant("functions"), '1', '2', '3', '4'], values='size',
|
||||||
|
hover_data=['size'])
|
||||||
|
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
||||||
|
print("finished")
|
||||||
|
|
||||||
|
|
||||||
|
fig.write_image("output.svg")
|
||||||
|
print("written")
|
||||||
|
|
@ -35,7 +35,7 @@ pub fn analyze_text_bloat(elf: ElfReader<'_>, csv: bool) -> Result<()> {
|
||||||
symbol_sizes.sort_by_key(|&(_, size)| size);
|
symbol_sizes.sort_by_key(|&(_, size)| size);
|
||||||
symbol_sizes.reverse();
|
symbol_sizes.reverse();
|
||||||
|
|
||||||
let depth = 3;
|
let depth = 4;
|
||||||
|
|
||||||
if csv {
|
if csv {
|
||||||
println!(
|
println!(
|
||||||
|
|
@ -54,8 +54,8 @@ pub fn analyze_text_bloat(elf: ElfReader<'_>, csv: bool) -> Result<()> {
|
||||||
if csv {
|
if csv {
|
||||||
println!("{size},{components}");
|
println!("{size},{components}");
|
||||||
} else {
|
} else {
|
||||||
|
println!("{size} {components}");
|
||||||
}
|
}
|
||||||
println!("{size} {components}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -69,8 +69,10 @@ fn symbol_components(sym: &str, depth: usize, csv: bool) -> Result<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut components = if demangled.starts_with('<') {
|
let mut components = if demangled.starts_with('<') {
|
||||||
let qpath = parse_qpath(&demangled).context("invalid qpath")?;
|
parse_qpath(&demangled)
|
||||||
qpath_components(qpath)?
|
.context("invalid qpath")
|
||||||
|
.and_then(|qpath| qpath_components(qpath))
|
||||||
|
.unwrap_or_else(|_| demangled.split("::").collect::<Vec<_>>())
|
||||||
} else {
|
} else {
|
||||||
// normal path
|
// normal path
|
||||||
demangled.split("::").collect::<Vec<_>>()
|
demangled.split("::").collect::<Vec<_>>()
|
||||||
|
|
@ -79,7 +81,7 @@ fn symbol_components(sym: &str, depth: usize, csv: bool) -> Result<String> {
|
||||||
if components.len() >= depth {
|
if components.len() >= depth {
|
||||||
components.truncate(depth);
|
components.truncate(depth);
|
||||||
} else {
|
} else {
|
||||||
components.extend(std::iter::repeat("").take(depth - components.len()));
|
components.extend(std::iter::repeat("_").take(depth - components.len()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let components = components
|
let components = components
|
||||||
|
|
@ -106,10 +108,17 @@ struct QPath<'a> {
|
||||||
|
|
||||||
fn qpath_components(qpath: QPath<'_>) -> Result<Vec<&str>> {
|
fn qpath_components(qpath: QPath<'_>) -> Result<Vec<&str>> {
|
||||||
if qpath.qself.starts_with('<') {
|
if qpath.qself.starts_with('<') {
|
||||||
let sub_qpath = parse_qpath(qpath.qself)?;
|
if let Ok(sub_qpath) = parse_qpath(qpath.qself) {
|
||||||
let mut sub_components = qpath_components(sub_qpath)?;
|
let mut sub_components = qpath_components(sub_qpath)?;
|
||||||
sub_components.extend(qpath.pathy_bit.split("::"));
|
sub_components.extend(qpath.pathy_bit.split("::"));
|
||||||
Ok(sub_components)
|
Ok(sub_components)
|
||||||
|
} else {
|
||||||
|
Ok(qpath
|
||||||
|
.qself
|
||||||
|
.split("::")
|
||||||
|
.chain(qpath.pathy_bit.split("::"))
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(qpath
|
Ok(qpath
|
||||||
.qself
|
.qself
|
||||||
|
|
@ -202,7 +211,7 @@ mod tests {
|
||||||
fn path_debug_helper() {
|
fn path_debug_helper() {
|
||||||
// <<std::path::Components as core::fmt::Debug>::fmt::DebugHelper as core::fmt::Debug>::fmt::h4f87ac80fb33df05
|
// <<std::path::Components as core::fmt::Debug>::fmt::DebugHelper as core::fmt::Debug>::fmt::h4f87ac80fb33df05
|
||||||
let sym = "_ZN106_$LT$$LT$std..path..Iter$u20$as$u20$core..fmt..Debug$GT$..fmt..DebugHelper$u20$as$u20$core..fmt..Debug$GT$3fmt17h4f87ac80fb33df05E";
|
let sym = "_ZN106_$LT$$LT$std..path..Iter$u20$as$u20$core..fmt..Debug$GT$..fmt..DebugHelper$u20$as$u20$core..fmt..Debug$GT$3fmt17h4f87ac80fb33df05E";
|
||||||
let components = symbol_components(sym, 6).unwrap();
|
let components = symbol_components(sym, 6, true).unwrap();
|
||||||
|
|
||||||
assert_eq!(components, "std,path,Iter,fmt,DebugHelper,fmt")
|
assert_eq!(components, "std,path,Iter,fmt,DebugHelper,fmt")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue