Add custom timing support for comet
This commit is contained in:
parent
d1e936fb25
commit
2e0c03923c
5 changed files with 24 additions and 17 deletions
|
|
@ -206,10 +206,9 @@ pub fn run() -> impl Stream<Item = Event> {
|
||||||
span::Stage::Present(window) => {
|
span::Stage::Present(window) => {
|
||||||
Span::Present { window }
|
Span::Present { window }
|
||||||
}
|
}
|
||||||
span::Stage::Custom(
|
span::Stage::Custom(name) => {
|
||||||
window,
|
Span::Custom { name }
|
||||||
name,
|
}
|
||||||
) => Span::Custom { window, name },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = output
|
let _ = output
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ pub enum Span {
|
||||||
window: window::Id,
|
window: window::Id,
|
||||||
},
|
},
|
||||||
Custom {
|
Custom {
|
||||||
window: window::Id,
|
|
||||||
name: String,
|
name: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -70,9 +69,7 @@ impl Span {
|
||||||
Span::Prepare { primitive, .. } => Stage::Prepare(*primitive),
|
Span::Prepare { primitive, .. } => Stage::Prepare(*primitive),
|
||||||
Span::Render { primitive, .. } => Stage::Render(*primitive),
|
Span::Render { primitive, .. } => Stage::Render(*primitive),
|
||||||
Span::Present { window } => Stage::Present(*window),
|
Span::Present { window } => Stage::Present(*window),
|
||||||
Span::Custom { window, name } => {
|
Span::Custom { name, .. } => Stage::Custom(name.clone()),
|
||||||
Stage::Custom(*window, name.clone())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -90,7 +87,7 @@ pub enum Stage {
|
||||||
Present(window::Id),
|
Present(window::Id),
|
||||||
Prepare(Primitive),
|
Prepare(Primitive),
|
||||||
Render(Primitive),
|
Render(Primitive),
|
||||||
Custom(window::Id, String),
|
Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Stage {
|
impl std::fmt::Display for Stage {
|
||||||
|
|
@ -105,7 +102,7 @@ impl std::fmt::Display for Stage {
|
||||||
Stage::Prepare(_) => "Prepare",
|
Stage::Prepare(_) => "Prepare",
|
||||||
Stage::Render(_) => "Render",
|
Stage::Render(_) => "Render",
|
||||||
Stage::Present(_) => "Present",
|
Stage::Present(_) => "Present",
|
||||||
Stage::Custom(_, name) => name,
|
Stage::Custom(name) => name,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,16 @@ pub fn present(window: window::Id) -> Span {
|
||||||
internal::present(window)
|
internal::present(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn time(window: window::Id, name: impl AsRef<str>) -> Span {
|
pub fn time(name: impl Into<String>) -> Span {
|
||||||
internal::time(window, name)
|
internal::time(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn time_with<T>(name: impl Into<String>, f: impl FnOnce() -> T) -> T {
|
||||||
|
let span = time(name);
|
||||||
|
let result = f();
|
||||||
|
span.finish();
|
||||||
|
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn skip_next_timing() {
|
pub fn skip_next_timing() {
|
||||||
|
|
@ -201,8 +209,8 @@ mod internal {
|
||||||
span(span::Stage::Present(window))
|
span(span::Stage::Present(window))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn time(window: window::Id, name: impl AsRef<str>) -> Span {
|
pub fn time(name: impl Into<String>) -> Span {
|
||||||
span(span::Stage::Custom(window, name.as_ref().to_owned()))
|
span(span::Stage::Custom(name.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn skip_next_timing() {
|
pub fn skip_next_timing() {
|
||||||
|
|
@ -312,7 +320,7 @@ mod internal {
|
||||||
Span
|
Span
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn time(_window: window::Id, _name: impl AsRef<str>) -> Span {
|
pub fn time(_name: impl Into<String>) -> Span {
|
||||||
Span
|
Span
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,4 @@ pub use crate::core::svg;
|
||||||
pub use crate::core::text::{self, Text};
|
pub use crate::core::text::{self, Text};
|
||||||
pub use crate::renderer::graphics;
|
pub use crate::renderer::graphics;
|
||||||
|
|
||||||
pub use iced_debug as debug;
|
|
||||||
|
|
||||||
pub use widget::Widget;
|
pub use widget::Widget;
|
||||||
|
|
|
||||||
|
|
@ -533,6 +533,11 @@ pub use Length::{Fill, FillPortion, Shrink};
|
||||||
pub use alignment::Horizontal::{Left, Right};
|
pub use alignment::Horizontal::{Left, Right};
|
||||||
pub use alignment::Vertical::{Bottom, Top};
|
pub use alignment::Vertical::{Bottom, Top};
|
||||||
|
|
||||||
|
pub mod debug {
|
||||||
|
//! Debug your applications.
|
||||||
|
pub use iced_debug::{Span, skip_next_timing, time, time_with};
|
||||||
|
}
|
||||||
|
|
||||||
pub mod task {
|
pub mod task {
|
||||||
//! Create runtime tasks.
|
//! Create runtime tasks.
|
||||||
pub use crate::runtime::task::{Handle, Task};
|
pub use crate::runtime::task::{Handle, Task};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue