Commit 9a8880be authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

gate histogram behind debug_assertions

parent 26547c3c
...@@ -951,40 +951,43 @@ pub async fn analyse_ecmascript_module_internal( ...@@ -951,40 +951,43 @@ pub async fn analyse_ecmascript_module_internal(
.instrument(span) .instrument(span)
.await?; .await?;
static HISTOGRAM: once_cell::sync::Lazy<Option<String>> = #[cfg(debug_assertions)]
once_cell::sync::Lazy::new(|| std::env::var("JSVALUE_HISTOGRAM").ok());
if let Some(p) = HISTOGRAM.as_ref()
&& path.path.ends_with(p)
{ {
let mut histogram = vec![]; static HISTOGRAM: once_cell::sync::Lazy<Option<String>> =
let mut add = |v: u32| { once_cell::sync::Lazy::new(|| std::env::var("JSVALUE_HISTOGRAM").ok());
let scaled = (v / 10) as usize; if let Some(p) = HISTOGRAM.as_ref()
if histogram.len() < scaled + 1 { && path.path.ends_with(p)
histogram.resize(scaled + 1, 0); {
} let mut histogram = vec![];
histogram[scaled] += 1usize; let mut add = |v: u32| {
}; let scaled = (v / 10) as usize;
for (name, v) in &var_graph.values { if histogram.len() < scaled + 1 {
let size = v.total_nodes(); histogram.resize(scaled + 1, 0);
add(size); }
if size > 100 { histogram[scaled] += 1usize;
println!("big jsvalue {name:?} {size} {v}") };
} for (name, v) in &var_graph.values {
}
for effect in &var_graph.effects {
for v in effect.values() {
let size = v.total_nodes(); let size = v.total_nodes();
add(size); add(size);
if size > 100 { if size > 100 {
println!("big jsvalue in effect {size} {v}") println!("big jsvalue {name:?} {size} {v}")
} }
} }
} for effect in &var_graph.effects {
if !histogram.is_empty() { for v in effect.values() {
let scale = 150f32 / (*histogram.iter().max().unwrap() as f32); let size = v.total_nodes();
for (i, count) in histogram.into_iter().enumerate() { add(size);
let bar = "*".repeat((count as f32 * scale) as usize); if size > 100 {
println!("{i:3}: {bar} ({count})"); println!("big jsvalue in effect {size} {v}")
}
}
}
if !histogram.is_empty() {
let scale = 150f32 / (*histogram.iter().max().unwrap() as f32);
for (i, count) in histogram.into_iter().enumerate() {
let bar = "*".repeat((count as f32 * scale) as usize);
println!("{i:3}: {bar} ({count})");
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment