pub async fn cycle_completed(&mut self, iteration: u64, now: Instant) {
        let current_interval_duration = now - self.last_snapshot_time;
        let current_interval_iter_count = iteration - self.last_snapshot_cycle;

        // Don't snapshot if we're too close to the end of the run,
        // to avoid excessively small samples:
        let far_from_the_end = match self.run_duration {
            config::Interval::Time(d) => now < self.start_time + d - current_interval_duration / 2,
            config::Interval::Count(count) => iteration < count - current_interval_iter_count / 2,
            config::Interval::Unbounded => true,
        };

        match self.sampling {
            Interval::Time(d) => {
                if now > self.last_snapshot_time + d && far_from_the_end {
                    self.send_stats().await;
                    self.last_snapshot_time += d;
                }
            }
            Interval::Count(cnt) => {
                if iteration > self.last_snapshot_cycle + cnt && far_from_the_end {
                    self.send_stats().await;
                    self.last_snapshot_cycle += cnt;
                }
            }
            Interval::Unbounded => {}
        }
    }
/// Should be called when a workload iteration finished.
/// If there comes the time, it will send the stats to the output.
Should be called when a workload iteration finished.
If there comes the time, it will send the stats to the output.
Should be called when a workload iteration finished . If there comes the time it will send the stats to the output .
pub async fn cycle_completed(&mut self, iteration: u64, now: Instant) {
        let current_interval_duration = now - self.last_snapshot_time;
        let current_interval_iter_count = iteration - self.last_snapshot_cycle;
        // Don't snapshot if we're too close to the end of the run,
        // to avoid excessively small samples:
        let far_from_the_end = match self.run_duration {
            config::Interval::Time(d) => now < self.start_time + d - current_interval_duration / 2,
            config::Interval::Count(count) => iteration < count - current_interval_iter_count / 2,
            config::Interval::Unbounded => true,
        };
        match self.sampling {
            Interval::Time(d) => {
                if now > self.last_snapshot_time + d && far_from_the_end {
                    self.send_stats().await;
                    self.last_snapshot_time += d;
                }
            }
            Interval::Count(cnt) => {
                if iteration > self.last_snapshot_cycle + cnt && far_from_the_end {
                    self.send_stats().await;
                    self.last_snapshot_cycle += cnt;
                }
            }
            Interval::Unbounded => {}
        }
    }
pub async fn cycle_completed ( & mut self , iteration : u64 , now : Instant ) { let current_interval_duration = now - self . last_snapshot_time ; let current_interval_iter_count = iteration - self . last_snapshot_cycle ; // Don't snapshot if we're too close to the end of the run, // to avoid excessively small samples: let far_from_the_end = match self . run_duration { config :: Interval :: Time ( d ) => now < self . start_time + d - current_interval_duration / 2 , config :: Interval :: Count ( count ) => iteration < count - current_interval_iter_count / 2 , config :: Interval :: Unbounded => true , } ; match self . sampling { Interval :: Time ( d ) => { if now > self . last_snapshot_time + d && far_from_the_end { self . send_stats ( ) . await ; self . last_snapshot_time += d ; } } Interval :: Count ( cnt ) => { if iteration > self . last_snapshot_cycle + cnt && far_from_the_end { self . send_stats ( ) . await ; self . last_snapshot_cycle += cnt ; } } Interval :: Unbounded => { } } }
Should be called when a workload iteration finished.
Should be called when a workload iteration finished .
&mut self
iteration
u64
now
Instant
&mut self
iteration
u64
now
Instant