diff options
author | Delan Azabani <dazabani@igalia.com> | 2024-11-15 17:10:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 09:10:01 +0000 |
commit | aa7116c75d2f13f554ce4db162344aaea59e60b0 (patch) | |
tree | 6b23fa65221101ac202e0742dc749c255627beb1 /components/shared/profile/lib.rs | |
parent | 495cceb7de813f6f1936d77821e8cf04ca2857cd (diff) | |
download | servo-aa7116c75d2f13f554ce4db162344aaea59e60b0.tar.gz servo-aa7116c75d2f13f554ce4db162344aaea59e60b0.zip |
Plumb time profiler output into tracing (#34238)
* Plumb time profiler output into tracing
Signed-off-by: Delan Azabani <dazabani@igalia.com>
* Enter the span tightly around the callback
Signed-off-by: Delan Azabani <dazabani@igalia.com>
* Use `info_span!()` shorthand
Signed-off-by: Delan Azabani <dazabani@igalia.com>
---------
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Diffstat (limited to 'components/shared/profile/lib.rs')
-rw-r--r-- | components/shared/profile/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/components/shared/profile/lib.rs b/components/shared/profile/lib.rs index 7be3d265d6c..fef2b255bea 100644 --- a/components/shared/profile/lib.rs +++ b/components/shared/profile/lib.rs @@ -11,3 +11,17 @@ pub mod ipc; pub mod mem; pub mod time; + +/// Measure the given callback with the time profiler and (if enabled) tracing. +/// +/// `$category` must be const, because we use it to derive the span name. +#[macro_export] +macro_rules! time_profile { + ($category:expr, $meta:expr, $profiler_chan:expr, $($callback:tt)+) => {{ + #[cfg(feature = "tracing")] + let span = tracing::info_span!($category.variant_name(), servo_profiling = true); + #[cfg(not(feature = "tracing"))] + let span = (); + $crate::time::profile($category, $meta, $profiler_chan, span, $($callback)+) + }}; +} |