Profiler

Struct Profiler 

Source
pub struct Profiler<C: Category = DefaultCategory> { /* private fields */ }
Expand description

Main profiling interface with customizable categories

This struct provides a unified API for profiling that works in both stub and full modes. In stub mode, all methods are no-ops that compile away. In full mode, complete profiling functionality is provided.

§Examples

use quantum_pulse::Profiler;

// This code works identically in both modes
let result = Profiler::time("operation", || {
    perform_operation()
});

Implementations§

Source§

impl<C: Category> Profiler<C>

Source

pub fn new() -> Self

Create a new profiler with custom categories

Source

pub fn time<T, F>(_operation: &str, f: F) -> T
where F: FnOnce() -> T,

Source

pub fn time_with_category<T, F>(_operation: &str, _category: C, f: F) -> T
where F: FnOnce() -> T,

Source

pub async fn time_async<T, F, Fut>(_operation: &str, f: F) -> T
where F: FnOnce() -> Fut, Fut: Future<Output = T>,

Source

pub async fn time_async_with_category<T, F, Fut>( _operation: &str, _category: C, f: F, ) -> T
where F: FnOnce() -> Fut, Fut: Future<Output = T>,

Source

pub fn report() -> ProfileReport<C>

Get a comprehensive profiling report

Source

pub fn report_with_config(config: ReportConfig) -> ProfileReport<C>

Get a report with custom configuration

Source

pub fn reset()

Reset all profiling metrics

Source

pub fn reset_operation(operation: &str)

Reset metrics for a specific operation

Source

pub fn record(operation: &str, value_micros: u64)

Record a raw metric value (in microseconds)

Source

pub fn record_with_category(operation: &str, category: C, value_micros: u64)

Record a metric with a specific category

Source

pub fn has_data() -> bool

Check if any profiling data has been collected

Source

pub fn total_operations() -> u64

Get total number of operations recorded

Source

pub fn get_stats(operation: &str) -> Option<OperationStats>

Get statistics for a specific operation

Source

pub fn get_all_stats() -> HashMap<String, OperationStats>

Get all statistics

Trait Implementations§

Source§

impl<C: Category> Default for Profiler<C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Profiler<C>

§

impl<C> RefUnwindSafe for Profiler<C>
where C: RefUnwindSafe,

§

impl<C> Send for Profiler<C>

§

impl<C> Sync for Profiler<C>

§

impl<C> Unpin for Profiler<C>
where C: Unpin,

§

impl<C> UnwindSafe for Profiler<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.