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_queryImplementations§
Source§impl ProfileInterval
impl ProfileInterval
Sourcepub fn new(id: u64, label: &'static str, time: Instant) -> Self
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 messageslabel- A static string identifying this interval in log messagestime- The start time of the interval
Trait Implementations§
Source§impl Debug for ProfileInterval
impl Debug for ProfileInterval
Auto Trait Implementations§
impl Freeze for ProfileInterval
impl RefUnwindSafe for ProfileInterval
impl Send for ProfileInterval
impl Sync for ProfileInterval
impl Unpin for ProfileInterval
impl UnwindSafe for ProfileInterval
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