Skip to content

Commit f585f7e

Browse files
committed
Add frame name to its flame span
1 parent 29e046f commit f585f7e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

vm/src/frame.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,15 @@ impl Frame {
268268
}
269269
}
270270

271-
#[cfg_attr(feature = "flame-it", flame("Frame"))]
271+
// #[cfg_attr(feature = "flame-it", flame("Frame"))]
272272
pub fn run(&self, vm: &VirtualMachine) -> Result<ExecutionResult, PyObjectRef> {
273+
flame_guard!(format!("Frame::run({})", self.code.obj_name));
274+
// flame doesn't include notes in the html graph :(
275+
flame_note!(
276+
flame::StrCow::from("CodeObj name"),
277+
self.code.obj_name.clone().into()
278+
);
279+
273280
let filename = &self.code.source_path.to_string();
274281

275282
// This is the name of the object being run:

vm/src/macros.rs

+11
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,14 @@ macro_rules! flame_guard {
273273
let _guard = ::flame::start_guard($name);
274274
};
275275
}
276+
277+
macro_rules! flame_note {
278+
($name:expr, $desc:expr$(,)?) => {
279+
#[cfg(feature = "flame-it")]
280+
::flame::note($name, ::std::option::Option::Some($desc));
281+
};
282+
($name:expr$(,)?) => {
283+
#[cfg(feature = "flame-it")]
284+
::flame::note($name, ::std::option::Option::None);
285+
};
286+
}

0 commit comments

Comments
 (0)