Skip to main content

profile_phase

Function profile_phase 

Source
pub fn profile_phase<T, F: FnOnce() -> T>(
    phase: &str,
    f: F,
) -> (T, ProfileEntry)
Expand description

Profile a closure as a single phase and return (result, entry).

The returned ProfileEntry has items_processed set to 0; callers can adjust it or attach notes afterwards.

ยงExamples

use tensorlogic_compiler::profiling::profile_phase;

let (result, entry) = profile_phase("my_phase", || {
    // expensive work
    42
});
assert_eq!(result, 42);
assert_eq!(entry.phase, "my_phase");