servo/components/shared/profile/lib.rs
Delan Azabani aa7116c75d
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>
2024-11-15 09:10:01 +00:00

27 lines
1 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! This module contains APIs for the `profile` crate used generically in the
//! rest of Servo. These APIs are here instead of in `profile` so that these
//! modules won't have to depend on `profile`.
#![deny(unsafe_code)]
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)+)
}};
}