Skip to content

Commit

Permalink
Restructured everything to make profiling a feature of iced_winit.
Browse files Browse the repository at this point in the history
  • Loading branch information
bungoboingo authored and hecrj committed Jan 9, 2023
1 parent c5cd236 commit 4b6d379
Show file tree
Hide file tree
Showing 23 changed files with 181 additions and 251 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pkg/
Cargo.lock
.cargo/
dist/
traces/
13 changes: 5 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ smol = ["iced_futures/smol"]
palette = ["iced_core/palette"]
# Enables querying system information
system = ["iced_winit/system"]
# Enables tracing with Chrome
trace_chrome = [
"iced_winit/trace",
"iced_wgpu?/trace",
"iced_glow?/trace",
# Enables chrome traces
chrome-trace = [
"iced_winit/chrome-trace",
"iced_glutin?/trace",
"iced_profiling/tracing-chrome"
"iced_wgpu?/tracing",
"iced_glow?/tracing",
]

[badges]
Expand All @@ -59,7 +58,6 @@ members = [
"glow",
"glutin",
"lazy",
"profiling",
"native",
"style",
"wgpu",
Expand All @@ -75,7 +73,6 @@ iced_graphics = { version = "0.5", path = "graphics" }
iced_winit = { version = "0.6", path = "winit", features = ["application"] }
iced_glutin = { version = "0.5", path = "glutin", optional = true }
iced_glow = { version = "0.5", path = "glow", optional = true }
iced_profiling = { version = "0.1.0", path = "profiling", optional = true }
thiserror = "1.0"

[dependencies.image_rs]
Expand Down
Binary file removed docs/images/perfetto.png
Binary file not shown.
1 change: 0 additions & 1 deletion examples/integration_wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ publish = false
[dependencies]
iced_winit = { path = "../../winit" }
iced_wgpu = { path = "../../wgpu", features = ["webgl"] }
iced_profiling = { path = "../../profiling", features = ["tracing-chrome"]}
env_logger = "0.8"

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
7 changes: 0 additions & 7 deletions examples/integration_wgpu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use winit::{
event_loop::{ControlFlow, EventLoop},
};

use iced_profiling::info_span;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen::JsCast;
#[cfg(target_arch = "wasm32")]
Expand All @@ -41,9 +39,6 @@ pub fn main() {
#[cfg(not(target_arch = "wasm32"))]
env_logger::init();

// Initialize tracing
let _guard = iced_profiling::init();

// Initialize winit
let event_loop = EventLoop::new();

Expand Down Expand Up @@ -203,8 +198,6 @@ pub fn main() {
}
}
Event::RedrawRequested(_) => {
let _ = info_span!("Integration_WGPU", "DRAW").entered();

if resized {
let size = window.inner_size();

Expand Down
6 changes: 2 additions & 4 deletions glow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license = "MIT AND OFL-1.1"
repository = "https://github.com/iced-rs/iced"

[features]
trace = ["iced_profiling"]
svg = ["iced_graphics/svg"]
image = ["iced_graphics/image"]
png = ["iced_graphics/png"]
Expand Down Expand Up @@ -43,9 +42,8 @@ version = "0.5"
path = "../graphics"
features = ["font-fallback", "font-icons", "opengl"]

[dependencies.iced_profiling]
version = "0.1.0"
path = "../profiling"
[dependencies.tracing]
version = "0.1.6"
optional = true

[package.metadata.docs.rs]
Expand Down
6 changes: 3 additions & 3 deletions glow/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use glow::HasContext;

use std::cell::RefCell;

#[cfg(feature = "trace")]
use iced_profiling::info_span;
#[cfg(feature = "tracing")]
use tracing::info_span;

#[derive(Debug)]
pub(crate) struct Pipeline {
Expand Down Expand Up @@ -151,7 +151,7 @@ impl Pipeline {
images: &[layer::Image],
layer_bounds: Rectangle<u32>,
) {
#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]
let _ = info_span!("Glow::Image", "DRAW").entered();

unsafe {
Expand Down
6 changes: 3 additions & 3 deletions glow/src/quad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use glow::HasContext;
use iced_graphics::layer;
use iced_native::Rectangle;

#[cfg(feature = "trace")]
use iced_profiling::info_span;
#[cfg(feature = "tracing")]
use tracing::info_span;

#[derive(Debug)]
pub enum Pipeline {
Expand Down Expand Up @@ -45,7 +45,7 @@ impl Pipeline {
scale: f32,
bounds: Rectangle<u32>,
) {
#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]
let _ = info_span!("Glow::Quad", "DRAW").enter();

match self {
Expand Down
6 changes: 3 additions & 3 deletions glow/src/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use iced_graphics::triangle::{ColoredVertex2D, Vertex2D};
use glow::HasContext;
use std::marker::PhantomData;

#[cfg(feature = "trace")]
use iced_profiling::info_span;
#[cfg(feature = "tracing")]
use tracing::info_span;

const DEFAULT_VERTICES: usize = 1_000;
const DEFAULT_INDICES: usize = 1_000;
Expand Down Expand Up @@ -61,7 +61,7 @@ impl Pipeline {
transformation: Transformation,
scale_factor: f32,
) {
#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]
let _ = info_span!("Glow::Triangle", "DRAW").enter();

unsafe {
Expand Down
9 changes: 4 additions & 5 deletions glutin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]

[features]
trace = ["iced_profiling/tracing-chrome"]
trace = ["iced_winit/trace"]
debug = ["iced_winit/debug"]
system = ["iced_winit/system"]

Expand All @@ -37,7 +37,6 @@ version = "0.5"
path = "../graphics"
features = ["opengl"]

[dependencies.iced_profiling]
version = "0.1.0"
path = "../profiling"
optional = true
[dependencies.tracing]
version = "0.1.6"
optional = true
12 changes: 6 additions & 6 deletions glutin/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use iced_winit::{Clipboard, Command, Debug, Proxy, Settings};
use glutin::window::Window;
use std::mem::ManuallyDrop;

#[cfg(feature = "trace")]
use iced_profiling::{info_span, instrument::Instrument};
#[cfg(feature = "tracing")]
use tracing::{info_span, instrument::Instrument};

/// Runs an [`Application`] with an executor, compositor, and the provided
/// settings.
Expand All @@ -39,12 +39,12 @@ where
use glutin::ContextBuilder;

#[cfg(feature = "trace")]
let _guard = iced_profiling::init();
let _guard = iced_winit::Profiler::init();

let mut debug = Debug::new();
debug.startup_started();

#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]
let _ = info_span!("Application::Glutin", "RUN").entered();

let mut event_loop = EventLoopBuilder::with_user_event().build();
Expand Down Expand Up @@ -147,7 +147,7 @@ where
settings.exit_on_close_request,
);

#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]
let run_instance =
run_instance.instrument(info_span!("Application", "LOOP"));

Expand Down Expand Up @@ -350,7 +350,7 @@ async fn run_instance<A, E, C>(
messages.push(message);
}
event::Event::RedrawRequested(_) => {
#[cfg(feature = "trace")]
#[cfg(feature = "tracing")]
let _ = info_span!("Application", "FRAME").entered();

debug.render_started();
Expand Down
15 changes: 0 additions & 15 deletions profiling/Cargo.toml

This file was deleted.

61 changes: 0 additions & 61 deletions profiling/README.md

This file was deleted.

Loading

0 comments on commit 4b6d379

Please sign in to comment.