Skip to content

Commit

Permalink
Trim executable name when getting function color (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter authored Jul 29, 2024
1 parent 6d74d70 commit 1c60840
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/flamegraph/color/palettes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pub(super) mod rust {
use crate::flamegraph::color::BasicPalette;

pub(in super::super) fn resolve(name: &str) -> BasicPalette {
let name = name.split_once('`').map(|(_, after)| after).unwrap_or(name);
if name.starts_with("core::")
|| name.starts_with("std::")
|| name.starts_with("alloc::")
Expand Down Expand Up @@ -601,6 +602,14 @@ mod tests {
input: String::from("<std::something something::else"),
output: BasicPalette::Orange,
},
TestData {
input: String::from("my-app`std::sys::unix::thread::Thread::new::thread_start"),
output: BasicPalette::Orange,
},
TestData {
input: String::from("my-app`foobar::extent::Extent::write"),
output: BasicPalette::Aqua,
},
];
for elem in test_names.iter() {
let result = rust::resolve(&elem.input);
Expand Down

0 comments on commit 1c60840

Please sign in to comment.