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

Some cleanup changes #83

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo-puffin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn some_inner_function(_iteration_index: usize) {
burn_time(1);
}

fn some_macro_function(){
fn some_macro_function() {
profiling::function_scope!();
burn_time(5);
}
Expand Down Expand Up @@ -119,6 +119,6 @@ fn main() -> eframe::Result<()> {
eframe::run_native(
"eframe template",
native_options,
Box::new(|cc| Ok(Box::new(TemplateApp::new(cc))))
Box::new(|cc| Ok(Box::new(TemplateApp::new(cc)))),
)
}
3 changes: 2 additions & 1 deletion profiling/examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ fn some_other_function(iterations: usize) {
burn_time(5);

{
profiling::scope!("do iterations");
// Make this a non-literal to touch more of the API
profiling::scope!(&"do iterations".to_string());
for i in 0..iterations {
profiling::scope!(
"some_inner_function_that_sleeps",
Expand Down
8 changes: 4 additions & 4 deletions profiling/src/superluminal_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ macro_rules! scope {
#[macro_export]
macro_rules! function_scope {
() => {
let function_name = {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
$crate::scope!(function_name);
$crate::scope!(_function_name);
};
($data:expr) => {
let function_name = {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
$crate::scope!(function_name, $data);
$crate::scope!(_function_name, $data);
};
}

Expand Down
8 changes: 4 additions & 4 deletions profiling/src/tracing_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ macro_rules! scope {
};
}

// NOTE: Not supported as tracing does not support non literal spans. Use #[profiling::function] instead.
#[macro_export]
macro_rules! function_scope {
() => {
Expand All @@ -19,27 +18,28 @@ macro_rules! function_scope {
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let span = $crate::tracing::span!(
let _span = $crate::tracing::span!(
$crate::tracing::Level::INFO,
"function_scope",
"{}",
function_name
);
let _span_entered = span.enter();
let _span_entered = _span.enter();
};
($data:expr) => {
let function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let span = $crate::tracing::span!(
let _span = $crate::tracing::span!(
$crate::tracing::Level::INFO,
"function_scope",
tag = $data,
"{}",
function_name
);
let _span_entered = _span.enter();
};
}

Expand Down
18 changes: 9 additions & 9 deletions profiling/src/tracy_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,41 @@ macro_rules! scope {
_tracy_span.emit_text($data);
};
($name:expr) => {
let function_name = {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let _tracy_span = $crate::tracy_client::Client::running()
.expect("scope! without a running tracy_client::Client")
// Note: callstack_depth is 0 since this has significant overhead
.span_alloc(Some($name), function_name, file!(), line!(), 0);
.span_alloc(Some($name), _function_name, file!(), line!(), 0);
};
($name:expr, $data:expr) => {
let function_name = {
let _function_name = {
struct S;
let type_name = core::any::type_name::<S>();
&type_name[..type_name.len() - 3]
};
let _tracy_span = $crate::tracy_client::Client::running()
.expect("scope! without a running tracy_client::Client")
// Note: callstack_depth is 0 since this has significant overhead
.span_alloc(Some($name), function_name, file!(), line!(), 0);
.span_alloc(Some($name), _function_name, file!(), line!(), 0);
_tracy_span.emit_text($data);
};
}

#[macro_export]
macro_rules! function_scope {
() => {
$crate::tracy_client::span!();
let _tracy_span = $crate::tracy_client::span!();
};
($data:expr) => {
let location = $crate::tracy_client::span_location!();
let tracy_span = $crate::tracy_client::Client::running()
let _location = $crate::tracy_client::span_location!();
let _tracy_span = $crate::tracy_client::Client::running()
.expect("function_scope! without a running tracy_client::Client")
.span(location, 0);
tracy_span.emit_text($data);
.span(_location, 0);
_tracy_span.emit_text($data);
};
}

Expand Down
Loading