pub struct TensorProfiler { /* private fields */ }Expand description
Operation profiler for tensor computations.
Records individual operation entries and maintains running aggregates per operation name. Supports enable/disable toggling, configurable maximum entry count (oldest entries evicted on overflow), and tick-based ordering.
Implementations§
Source§impl TensorProfiler
impl TensorProfiler
Sourcepub fn new(max_entries: usize) -> Self
pub fn new(max_entries: usize) -> Self
Create a new profiler with the given maximum entry capacity.
The profiler starts enabled by default.
Sourcepub fn record(
&mut self,
op_name: &str,
duration_ns: u64,
input_elements: u64,
output_elements: u64,
)
pub fn record( &mut self, op_name: &str, duration_ns: u64, input_elements: u64, output_elements: u64, )
Record an operation.
If the profiler is disabled the call is a no-op. When the entry buffer is full the oldest entry is evicted (FIFO).
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns true if the profiler is currently recording.
Sourcepub fn get_profile(&self, op_name: &str) -> Option<&OpProfile>
pub fn get_profile(&self, op_name: &str) -> Option<&OpProfile>
Look up the aggregate profile for a given operation name.
Sourcepub fn avg_ns(&self, op_name: &str) -> Option<f64>
pub fn avg_ns(&self, op_name: &str) -> Option<f64>
Average duration per call in nanoseconds for the given op.
Sourcepub fn throughput(&self, op_name: &str) -> Option<f64>
pub fn throughput(&self, op_name: &str) -> Option<f64>
Throughput in elements/second for the given op.
Computed as total_output_elements / (total_ns / 1e9).
Sourcepub fn hottest_ops(&self, n: usize) -> Vec<&OpProfile>
pub fn hottest_ops(&self, n: usize) -> Vec<&OpProfile>
Return the top n operations by cumulative time (descending).
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of entries currently stored.
Sourcepub fn stats(&self) -> ProfilerStats
pub fn stats(&self) -> ProfilerStats
Return a snapshot of summary statistics.
Auto Trait Implementations§
impl Freeze for TensorProfiler
impl RefUnwindSafe for TensorProfiler
impl Send for TensorProfiler
impl Sync for TensorProfiler
impl Unpin for TensorProfiler
impl UnsafeUnpin for TensorProfiler
impl UnwindSafe for TensorProfiler
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more