LCOV - code coverage report
Current view: top level - libs/utils/src - elapsed_accum.rs (source / functions) Coverage Total Hit
Test: 1e20c4f2b28aa592527961bb32170ebbd2c9172f.info Lines: 87.5 % 16 14
Test Date: 2025-07-16 12:29:03 Functions: 71.4 % 7 5

            Line data    Source code
       1              : use std::time::{Duration, Instant};
       2              : 
       3              : #[derive(Default)]
       4              : pub struct ElapsedAccum {
       5              :     accum: Duration,
       6              : }
       7              : 
       8              : impl ElapsedAccum {
       9       139149 :     pub fn get(&self) -> Duration {
      10       139149 :         self.accum
      11       139149 :     }
      12           20 :     pub fn guard(&mut self) -> impl Drop + '_ {
      13           20 :         let start = Instant::now();
      14           20 :         scopeguard::guard(start, |last_wait_at| {
      15           20 :             self.accum += Instant::now() - last_wait_at;
      16           20 :         })
      17           20 :     }
      18              : 
      19            8 :     pub async fn measure<Fut, O>(&mut self, fut: Fut) -> O
      20            8 :     where
      21            8 :         Fut: Future<Output = O>,
      22            0 :     {
      23            8 :         let _guard = self.guard();
      24            8 :         fut.await
      25            0 :     }
      26              : }
        

Generated by: LCOV version 2.1-beta