Skip to main content

format_elapsed

Function format_elapsed 

Source
pub fn format_elapsed(elapsed: Duration) -> String
Expand description

Format a Duration as a compact HHh MMm SSs string.

Intended for embedding elapsed-time information into log messages emitted by an algorithm that tracks its own start instant, e.g.:

use std::time::Instant;
use pmcore::logs::format_elapsed;

let start = Instant::now();
// ... do work ...
tracing::info!("cycle finished in {}", format_elapsed(start.elapsed()));