diff options
author | 2023-01-09 19:10:45 +0100 | |
---|---|---|
committer | 2023-01-09 19:10:45 +0100 | |
commit | 07d755c6a270bd46fe9752ed57b3ceaddda1f081 (patch) | |
tree | cbd8f75d8cd6beeb3c04cbedc0127f2e17b70f56 /glutin | |
parent | ba20ac8e49aedfa9d822d71784587d0635cec4f8 (diff) | |
parent | 2e5dc1f37a32e1f3aaa6db2aa9cf9c95e83bff42 (diff) | |
download | iced-07d755c6a270bd46fe9752ed57b3ceaddda1f081.tar.gz iced-07d755c6a270bd46fe9752ed57b3ceaddda1f081.tar.bz2 iced-07d755c6a270bd46fe9752ed57b3ceaddda1f081.zip |
Merge pull request #1565 from bungoboingo/feat/tracing
[Feature] Profiling
Diffstat (limited to '')
-rw-r--r-- | glutin/Cargo.toml | 5 | ||||
-rw-r--r-- | glutin/src/application.rs | 44 |
2 files changed, 37 insertions, 12 deletions
diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index 022457b1..304170cd 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -11,6 +11,7 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"] categories = ["gui"] [features] +trace = ["iced_winit/trace"] debug = ["iced_winit/debug"] system = ["iced_winit/system"] @@ -35,3 +36,7 @@ features = ["application"] version = "0.5" path = "../graphics" features = ["opengl"] + +[dependencies.tracing] +version = "0.1.6" +optional = true
\ No newline at end of file diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 3e9d11f9..1464bb2d 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -17,6 +17,9 @@ use iced_winit::{Clipboard, Command, Debug, Proxy, Settings}; use glutin::window::Window; use std::mem::ManuallyDrop; +#[cfg(feature = "tracing")] +use tracing::{info_span, instrument::Instrument}; + /// Runs an [`Application`] with an executor, compositor, and the provided /// settings. pub fn run<A, E, C>( @@ -35,9 +38,15 @@ where use glutin::platform::run_return::EventLoopExtRunReturn; use glutin::ContextBuilder; + #[cfg(feature = "trace")] + let _guard = iced_winit::Profiler::init(); + let mut debug = Debug::new(); debug.startup_started(); + #[cfg(feature = "tracing")] + let _ = info_span!("Application::Glutin", "RUN").entered(); + let mut event_loop = EventLoopBuilder::with_user_event().build(); let proxy = event_loop.create_proxy(); @@ -124,18 +133,26 @@ where let (mut sender, receiver) = mpsc::unbounded(); - let mut instance = Box::pin(run_instance::<A, E, C>( - application, - compositor, - renderer, - runtime, - proxy, - debug, - receiver, - context, - init_command, - settings.exit_on_close_request, - )); + let mut instance = Box::pin({ + let run_instance = run_instance::<A, E, C>( + application, + compositor, + renderer, + runtime, + proxy, + debug, + receiver, + context, + init_command, + settings.exit_on_close_request, + ); + + #[cfg(feature = "tracing")] + let run_instance = + run_instance.instrument(info_span!("Application", "LOOP")); + + run_instance + }); let mut context = task::Context::from_waker(task::noop_waker_ref()); @@ -333,6 +350,9 @@ async fn run_instance<A, E, C>( messages.push(message); } event::Event::RedrawRequested(_) => { + #[cfg(feature = "tracing")] + let _ = info_span!("Application", "FRAME").entered(); + debug.render_started(); #[allow(unsafe_code)] |