ProfileInterval

Struct ProfileInterval 

Source
pub struct ProfileInterval { /* private fields */ }
Expand description

A profiling interval that logs when created and dropped.

ProfileInterval logs a BEGIN message when created and an END message with elapsed duration when dropped. Each interval has a unique ID to correlate BEGIN/END pairs, which is especially useful when profiling nested operations.

Unlike PerfwarnInterval, this type:

  • Always logs (no threshold)
  • Logs both BEGIN and END messages
  • Does not contribute to task statistics
  • Is intended for temporary profiling that should be removed before committing

§Usage

This type is typically not created directly. Instead, use the profile_begin! macro which properly sets up the interval with source location information.

§Example

logwise::declare_logging_domain!();
// Using profile_begin! for manual interval management
let interval = logwise::profile_begin!("database_query");
perform_operation();
// BEGIN logged when created, END logged when dropped
drop(interval);

§Log Output

The interval produces log messages like:

PROFILE: BEGIN [id=1] src/main.rs:10:5 [0ns] database_query
PROFILE: END [id=1] [elapsed: 150µs] database_query

Implementations§

Source§

impl ProfileInterval

Source

pub fn new(id: u64, label: &'static str, time: Instant) -> Self

Creates a new profile interval.

Do not use this manually. Instead use the profile_begin! macro which properly captures source location information.

§Arguments
  • id - Unique identifier for correlating BEGIN/END messages
  • label - A static string identifying this interval in log messages
  • time - The start time of the interval
Source

pub fn id(&self) -> u64

Returns the unique ID of this profile interval.

Trait Implementations§

Source§

impl Debug for ProfileInterval

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for ProfileInterval

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.