pub struct ThreadMetrics {Show 17 fields
pub thread_id: ThreadId,
pub cpu_time_ns: u64,
pub context_switches: u64,
pub voluntary_yields: u64,
pub involuntary_preemptions: u64,
pub peak_stack_usage: usize,
pub current_stack_usage: usize,
pub page_faults: u64,
pub user_time_ns: u64,
pub kernel_time_ns: u64,
pub created_at: Instant,
pub last_active: Instant,
pub priority_changes: u32,
pub memory_allocations: u64,
pub memory_deallocations: u64,
pub total_memory_allocated: u64,
pub current_memory_usage: u64,
}
Expand description
Per-thread metrics tracking.
Fields§
§thread_id: ThreadId
Thread ID
cpu_time_ns: u64
Total CPU time consumed (nanoseconds)
context_switches: u64
Number of context switches
voluntary_yields: u64
Number of voluntary yields
involuntary_preemptions: u64
Number of involuntary preemptions
peak_stack_usage: usize
Peak stack usage (bytes)
current_stack_usage: usize
Current stack usage (bytes)
page_faults: u64
Number of page faults
user_time_ns: u64
Time spent in user mode (nanoseconds)
kernel_time_ns: u64
Time spent in kernel mode (nanoseconds)
created_at: Instant
Thread creation time
last_active: Instant
Last active time
priority_changes: u32
Priority changes
memory_allocations: u64
Memory allocations
memory_deallocations: u64
Memory deallocations
total_memory_allocated: u64
Total memory allocated (bytes)
current_memory_usage: u64
Current memory usage (bytes)
Implementations§
Source§impl ThreadMetrics
impl ThreadMetrics
Sourcepub fn add_cpu_time(&mut self, duration: Duration, is_user_mode: bool)
pub fn add_cpu_time(&mut self, duration: Duration, is_user_mode: bool)
Update CPU time metrics.
Sourcepub fn record_context_switch(&mut self, voluntary: bool)
pub fn record_context_switch(&mut self, voluntary: bool)
Record a context switch.
Sourcepub fn update_stack_usage(&mut self, current_usage: usize)
pub fn update_stack_usage(&mut self, current_usage: usize)
Update stack usage metrics.
Sourcepub fn record_allocation(&mut self, size: u64)
pub fn record_allocation(&mut self, size: u64)
Record memory allocation.
Sourcepub fn record_deallocation(&mut self, size: u64)
pub fn record_deallocation(&mut self, size: u64)
Record memory deallocation.
Sourcepub fn cpu_utilization(&self) -> f64
pub fn cpu_utilization(&self) -> f64
Calculate CPU utilization percentage.
Sourcepub fn preemption_rate(&self) -> f64
pub fn preemption_rate(&self) -> f64
Calculate preemption rate.
Trait Implementations§
Source§impl Clone for ThreadMetrics
impl Clone for ThreadMetrics
Source§fn clone(&self) -> ThreadMetrics
fn clone(&self) -> ThreadMetrics
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 ThreadMetrics
impl RefUnwindSafe for ThreadMetrics
impl Send for ThreadMetrics
impl Sync for ThreadMetrics
impl Unpin for ThreadMetrics
impl UnwindSafe for ThreadMetrics
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