From 232ff03441e76e10be76553d29dfa57eafe99b39 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 13 Sep 2023 08:34:03 +0200 Subject: [PATCH] Standardize puffin profile scope definitions --- crates/eframe/src/lib.rs | 4 ++-- crates/egui-wgpu/src/lib.rs | 43 ++++++++++++++++++++-------------- crates/egui-winit/src/lib.rs | 44 +++++++++++++++++++---------------- crates/egui/src/lib.rs | 4 ++-- crates/egui_extras/src/lib.rs | 5 ++-- crates/egui_glow/src/lib.rs | 41 ++++++++++++++++++-------------- 6 files changed, 79 insertions(+), 62 deletions(-) diff --git a/crates/eframe/src/lib.rs b/crates/eframe/src/lib.rs index 2972d672740..dab4aae61e7 100644 --- a/crates/eframe/src/lib.rs +++ b/crates/eframe/src/lib.rs @@ -324,7 +324,6 @@ pub type Result = std::result::Result; // --------------------------------------------------------------------------- -#[cfg(not(target_arch = "wasm32"))] mod profiling_scopes { #![allow(unused_macros)] #![allow(unused_imports)] @@ -333,6 +332,7 @@ mod profiling_scopes { macro_rules! profile_function { ($($arg: tt)*) => { #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. puffin::profile_function!($($arg)*); }; } @@ -342,11 +342,11 @@ mod profiling_scopes { macro_rules! profile_scope { ($($arg: tt)*) => { #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. puffin::profile_scope!($($arg)*); }; } pub(crate) use profile_scope; } -#[cfg(not(target_arch = "wasm32"))] pub(crate) use profiling_scopes::*; diff --git a/crates/egui-wgpu/src/lib.rs b/crates/egui-wgpu/src/lib.rs index 7d0a3506cf4..9e87ffd12a7 100644 --- a/crates/egui-wgpu/src/lib.rs +++ b/crates/egui-wgpu/src/lib.rs @@ -203,22 +203,29 @@ pub fn depth_format_from_bits(depth_buffer: u8, stencil_buffer: u8) -> Option { - #[cfg(feature = "puffin")] - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} -pub(crate) use profile_function; - -/// Profiling macro for feature "puffin" -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(feature = "puffin")] - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; +mod profiling_scopes { + #![allow(unused_macros)] + #![allow(unused_imports)] + + /// Profiling macro for feature "puffin" + macro_rules! profile_function { + ($($arg: tt)*) => { + #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. + puffin::profile_function!($($arg)*); + }; + } + pub(crate) use profile_function; + + /// Profiling macro for feature "puffin" + macro_rules! profile_scope { + ($($arg: tt)*) => { + #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. + puffin::profile_scope!($($arg)*); + }; + } + pub(crate) use profile_scope; } -pub(crate) use profile_scope; + +pub(crate) use profiling_scopes::*; diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 8da31e2c6b5..28303519b96 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -894,26 +894,30 @@ fn translate_cursor(cursor_icon: egui::CursorIcon) -> Option { - #[cfg(feature = "puffin")] - puffin::profile_function!($($arg)*); - }; -} - -#[allow(unused_imports)] -pub(crate) use profile_function; - -/// Profiling macro for feature "puffin" -#[allow(unused_macros)] -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(feature = "puffin")] - puffin::profile_scope!($($arg)*); - }; +mod profiling_scopes { + #![allow(unused_macros)] + #![allow(unused_imports)] + + /// Profiling macro for feature "puffin" + macro_rules! profile_function { + ($($arg: tt)*) => { + #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. + puffin::profile_function!($($arg)*); + }; + } + pub(crate) use profile_function; + + /// Profiling macro for feature "puffin" + macro_rules! profile_scope { + ($($arg: tt)*) => { + #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. + puffin::profile_scope!($($arg)*); + }; + } + pub(crate) use profile_scope; } #[allow(unused_imports)] -pub(crate) use profile_scope; +pub(crate) use profiling_scopes::*; diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index 65f0aab7457..25edfc31058 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -640,8 +640,8 @@ mod profiling_scopes { /// Profiling macro for feature "puffin" macro_rules! profile_function { ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. puffin::profile_function!($($arg)*); }; } @@ -650,8 +650,8 @@ mod profiling_scopes { /// Profiling macro for feature "puffin" macro_rules! profile_scope { ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. puffin::profile_scope!($($arg)*); }; } diff --git a/crates/egui_extras/src/lib.rs b/crates/egui_extras/src/lib.rs index 3b020323e64..e8113ddf36b 100644 --- a/crates/egui_extras/src/lib.rs +++ b/crates/egui_extras/src/lib.rs @@ -39,8 +39,8 @@ mod profiling_scopes { /// Profiling macro for feature "puffin" macro_rules! profile_function { ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. puffin::profile_function!($($arg)*); }; } @@ -49,15 +49,14 @@ mod profiling_scopes { /// Profiling macro for feature "puffin" macro_rules! profile_scope { ($($arg: tt)*) => { - #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. puffin::profile_scope!($($arg)*); }; } pub(crate) use profile_scope; } -#[allow(unused_imports)] pub(crate) use profiling_scopes::*; // --------------------------------------------------------------------------- diff --git a/crates/egui_glow/src/lib.rs b/crates/egui_glow/src/lib.rs index 18d8ff870b9..27c3ebcc6f4 100644 --- a/crates/egui_glow/src/lib.rs +++ b/crates/egui_glow/src/lib.rs @@ -112,22 +112,29 @@ pub fn check_for_gl_error_impl(gl: &glow::Context, file: &str, line: u32, contex // --------------------------------------------------------------------------- -/// Profiling macro for feature "puffin" -macro_rules! profile_function { - ($($arg: tt)*) => { - #[cfg(feature = "puffin")] - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_function!($($arg)*); - }; -} -pub(crate) use profile_function; +mod profiling_scopes { + #![allow(unused_macros)] + #![allow(unused_imports)] + + /// Profiling macro for feature "puffin" + macro_rules! profile_function { + ($($arg: tt)*) => { + #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. + puffin::profile_function!($($arg)*); + }; + } + pub(crate) use profile_function; -/// Profiling macro for feature "puffin" -macro_rules! profile_scope { - ($($arg: tt)*) => { - #[cfg(feature = "puffin")] - #[cfg(not(target_arch = "wasm32"))] - puffin::profile_scope!($($arg)*); - }; + /// Profiling macro for feature "puffin" + macro_rules! profile_scope { + ($($arg: tt)*) => { + #[cfg(feature = "puffin")] + #[cfg(not(target_arch = "wasm32"))] // Disabled on web because of the coarse 1ms clock resolution there. + puffin::profile_scope!($($arg)*); + }; + } + pub(crate) use profile_scope; } -pub(crate) use profile_scope; + +pub(crate) use profiling_scopes::*;