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::Present { window }
|
||||
}
|
||||
span::Stage::Custom(
|
||||
window,
|
||||
name,
|
||||
) => Span::Custom { window, name },
|
||||
span::Stage::Custom(name) => {
|
||||
Span::Custom { name }
|
||||
}
|
||||
};
|
||||
|
||||
let _ = output
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ pub enum Span {
|
|||
window: window::Id,
|
||||
},
|
||||
Custom {
|
||||
window: window::Id,
|
||||
name: String,
|
||||
},
|
||||
}
|
||||
|
|
@ -70,9 +69,7 @@ impl Span {
|
|||
Span::Prepare { primitive, .. } => Stage::Prepare(*primitive),
|
||||
Span::Render { primitive, .. } => Stage::Render(*primitive),
|
||||
Span::Present { window } => Stage::Present(*window),
|
||||
Span::Custom { window, name } => {
|
||||
Stage::Custom(*window, name.clone())
|
||||
}
|
||||
Span::Custom { name, .. } => Stage::Custom(name.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -90,7 +87,7 @@ pub enum Stage {
|
|||
Present(window::Id),
|
||||
Prepare(Primitive),
|
||||
Render(Primitive),
|
||||
Custom(window::Id, String),
|
||||
Custom(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Stage {
|
||||
|
|
@ -105,7 +102,7 @@ impl std::fmt::Display for Stage {
|
|||
Stage::Prepare(_) => "Prepare",
|
||||
Stage::Render(_) => "Render",
|
||||
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)
|
||||
}
|
||||
|
||||
pub fn time(window: window::Id, name: impl AsRef<str>) -> Span {
|
||||
internal::time(window, name)
|
||||
pub fn time(name: impl Into<String>) -> Span {
|
||||
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() {
|
||||
|
|
@ -201,8 +209,8 @@ mod internal {
|
|||
span(span::Stage::Present(window))
|
||||
}
|
||||
|
||||
pub fn time(window: window::Id, name: impl AsRef<str>) -> Span {
|
||||
span(span::Stage::Custom(window, name.as_ref().to_owned()))
|
||||
pub fn time(name: impl Into<String>) -> Span {
|
||||
span(span::Stage::Custom(name.into()))
|
||||
}
|
||||
|
||||
pub fn skip_next_timing() {
|
||||
|
|
@ -312,7 +320,7 @@ mod internal {
|
|||
Span
|
||||
}
|
||||
|
||||
pub fn time(_window: window::Id, _name: impl AsRef<str>) -> Span {
|
||||
pub fn time(_name: impl Into<String>) -> Span {
|
||||
Span
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,4 @@ pub use crate::core::svg;
|
|||
pub use crate::core::text::{self, Text};
|
||||
pub use crate::renderer::graphics;
|
||||
|
||||
pub use iced_debug as debug;
|
||||
|
||||
pub use widget::Widget;
|
||||
|
|
|
|||
|
|
@ -533,6 +533,11 @@ pub use Length::{Fill, FillPortion, Shrink};
|
|||
pub use alignment::Horizontal::{Left, Right};
|
||||
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 {
|
||||
//! Create runtime tasks.
|
||||
pub use crate::runtime::task::{Handle, Task};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue