pub struct PropertyMetrics {
pub total_changes: usize,
pub observer_calls: usize,
pub avg_notification_time: Duration,
}Expand description
Performance metrics for an observable property
This struct provides insight into property usage patterns and observer notification performance, useful for debugging and performance optimization.
§Examples
use observable_property::ObservableProperty;
use std::sync::Arc;
let property = ObservableProperty::new(0);
property.subscribe(Arc::new(|old, new| {
println!("Value changed: {} -> {}", old, new);
}))?;
property.set(42)?;
property.set(100)?;
let metrics = property.get_metrics()?;
println!("Total changes: {}", metrics.total_changes);
println!("Observer calls: {}", metrics.observer_calls);
println!("Avg notification time: {:?}", metrics.avg_notification_time);Fields§
§total_changes: usizeTotal number of times the property value has changed
observer_calls: usizeTotal number of observer calls (notification events)
avg_notification_time: DurationAverage time taken to notify all observers per change
Trait Implementations§
Source§impl Clone for PropertyMetrics
impl Clone for PropertyMetrics
Source§fn clone(&self) -> PropertyMetrics
fn clone(&self) -> PropertyMetrics
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PropertyMetrics
impl RefUnwindSafe for PropertyMetrics
impl Send for PropertyMetrics
impl Sync for PropertyMetrics
impl Unpin for PropertyMetrics
impl UnsafeUnpin for PropertyMetrics
impl UnwindSafe for PropertyMetrics
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more