Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out lines which begin with '# ' in inferno-flamegraph #239

Merged
merged 3 commits into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/flamegraph/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions src/flamegraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ where
W: Write,
{
let mut reversed = StrStack::new();
let lines = lines.into_iter().filter(|line| !(line.is_empty() || line.starts_with("# ")));
jonhoo marked this conversation as resolved.
Show resolved Hide resolved

let (mut frames, time, ignored, delta_max) = if opt.reverse_stack_order {
if opt.no_sort {
warn!(
Expand Down
114 changes: 114 additions & 0 deletions tests/data/flamegraph/austin/flame.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/data/flamegraph/austin/flames.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# austin: 3.3.0
# interval: 100
# mode: wall

P6360;T6360;<frozen importlib._bootstrap>:_install_external_importers:1187;<frozen importlib._bootstrap>:_find_and_load:1007;<frozen importlib._bootstrap>:_find_and_load_unlocked:986;<frozen importlib._bootstrap>:_load_unlocked:680;<frozen importlib._bootstrap>:exec_module:838;<frozen importlib._bootstrap_external>:<module>:35;<frozen importlib._bootstrap>:_find_and_load:1007;<frozen importlib._bootstrap>:_find_and_load_unlocked:986;<frozen importlib._bootstrap>:_load_unlocked:680;<frozen importlib._bootstrap>:exec_module:768;<frozen importlib._bootstrap>:_call_with_frames_removed:228 105
P6360;T6360;<frozen importlib._bootstrap>:_install_external_importers:1187;<frozen importlib._bootstrap>:_find_and_load:1007;<frozen importlib._bootstrap>:_find_and_load_unlocked:986;<frozen importlib._bootstrap>:_load_unlocked:680;<frozen importlib._bootstrap>:exec_module:838;<frozen importlib._bootstrap_external>:<module>:828 186

# duration: 23873
2 changes: 2 additions & 0 deletions tests/data/flamegraph/bad-lines/bad-lines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions tests/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}