diff --git a/src/flamegraph/merge.rs b/src/flamegraph/merge.rs index dfd66e80..85c605fe 100644 --- a/src/flamegraph/merge.rs +++ b/src/flamegraph/merge.rs @@ -124,9 +124,6 @@ where let mut prev_line = None; for line in lines { let mut line = line.trim(); - if line.is_empty() { - continue; - } if !suppress_sort_check { if let Some(prev_line) = prev_line { diff --git a/src/flamegraph/mod.rs b/src/flamegraph/mod.rs index 2e84df70..35c4c36f 100644 --- a/src/flamegraph/mod.rs +++ b/src/flamegraph/mod.rs @@ -394,6 +394,11 @@ where W: Write, { let mut reversed = StrStack::new(); + let lines = lines + .into_iter() + .map(|line| line.trim()) + .filter(|line| !(line.is_empty() || line.starts_with("# "))); + let (mut frames, time, ignored, delta_max) = if opt.reverse_stack_order { if opt.no_sort { warn!( diff --git a/tests/data/flamegraph/austin/flame.svg b/tests/data/flamegraph/austin/flame.svg new file mode 100644 index 00000000..d19591cc --- /dev/null +++ b/tests/data/flamegraph/austin/flame.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + Flame Graph + + Reset Zoom + Search + + + + <frozen importlib._bootstrap_external>:<module>:35 (105 samples, 36.08%) + + <frozen importlib._bootstrap_external>:<module>:35 + + + <frozen importlib._bootstrap>:_find_and_load:1007 (105 samples, 36.08%) + + <frozen importlib._bootstrap>:_find_and_load:1007 + + + <frozen importlib._bootstrap>:_find_and_load_unlocked:986 (105 samples, 36.08%) + + <frozen importlib._bootstrap>:_find_and_load_unlocked:986 + + + <frozen importlib._bootstrap>:_load_unlocked:680 (105 samples, 36.08%) + + <frozen importlib._bootstrap>:_load_unlocked:680 + + + <frozen importlib._bootstrap>:exec_module:768 (105 samples, 36.08%) + + <frozen importlib._bootstrap>:exec_module:768 + + + <frozen importlib._bootstrap>:_call_with_frames_removed:228 (105 samples, 36.08%) + + <frozen importlib._bootstrap>:_call_with_frames_removed:228 + + + all (291 samples, 100%) + + + + + P6360 (291 samples, 100.00%) + + P6360 + + + T6360 (291 samples, 100.00%) + + T6360 + + + <frozen importlib._bootstrap>:_install_external_importers:1187 (291 samples, 100.00%) + + <frozen importlib._bootstrap>:_install_external_importers:1187 + + + <frozen importlib._bootstrap>:_find_and_load:1007 (291 samples, 100.00%) + + <frozen importlib._bootstrap>:_find_and_load:1007 + + + <frozen importlib._bootstrap>:_find_and_load_unlocked:986 (291 samples, 100.00%) + + <frozen importlib._bootstrap>:_find_and_load_unlocked:986 + + + <frozen importlib._bootstrap>:_load_unlocked:680 (291 samples, 100.00%) + + <frozen importlib._bootstrap>:_load_unlocked:680 + + + <frozen importlib._bootstrap>:exec_module:838 (291 samples, 100.00%) + + <frozen importlib._bootstrap>:exec_module:838 + + + <frozen importlib._bootstrap_external>:<module>:828 (186 samples, 63.92%) + + <frozen importlib._bootstrap_external>:<module>:828 + + + diff --git a/tests/data/flamegraph/austin/flames.txt b/tests/data/flamegraph/austin/flames.txt new file mode 100644 index 00000000..ff14155f --- /dev/null +++ b/tests/data/flamegraph/austin/flames.txt @@ -0,0 +1,8 @@ +# austin: 3.3.0 +# interval: 100 +# mode: wall + +P6360;T6360;:_install_external_importers:1187;:_find_and_load:1007;:_find_and_load_unlocked:986;:_load_unlocked:680;:exec_module:838;::35;:_find_and_load:1007;:_find_and_load_unlocked:986;:_load_unlocked:680;:exec_module:768;:_call_with_frames_removed:228 105 +P6360;T6360;:_install_external_importers:1187;:_find_and_load:1007;:_find_and_load_unlocked:986;:_load_unlocked:680;:exec_module:838;::828 186 + +# duration: 23873 diff --git a/tests/data/flamegraph/bad-lines/bad-lines.txt b/tests/data/flamegraph/bad-lines/bad-lines.txt index 872e1f6d..aaa878e6 100644 --- a/tests/data/flamegraph/bad-lines/bad-lines.txt +++ b/tests/data/flamegraph/bad-lines/bad-lines.txt @@ -6,3 +6,5 @@ cksum;main;cksum 19 THIS IS A BAD FRACTIONAL LINE 12V.43 noploop;[unknown] 2 noploop;main 274 + +noploop;main 274 diff --git a/tests/flamegraph.rs b/tests/flamegraph.rs index 9ce8ae77..5ce9a9af 100644 --- a/tests/flamegraph.rs +++ b/tests/flamegraph.rs @@ -883,3 +883,11 @@ fn flamegraph_flamechart() { test_flamegraph(input_file, expected_result_file, opts).unwrap(); } + +#[test] +fn flamegraph_austin() { + let input_file = "./tests/data/flamegraph/austin/flames.txt"; + let expected_result_file = "./tests/data/flamegraph/austin/flame.svg"; + let opts = flamegraph::Options::default(); + test_flamegraph(input_file, expected_result_file, opts).unwrap(); +}