1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::time::Duration;
/// Stats of [`AsyncTrainer`](crate::AsyncTrainer)`::train()`.
pub struct AsyncTrainStat {
    /// The number of samples pushed to the replay buffer per second.
    pub samples_per_sec: f32,

    /// Duration of training.
    pub duration: Duration,

    /// The number of optimization steps per second.
    pub opt_per_sec: f32,
}

impl AsyncTrainStat {
    /// Returns a formatted string.
    pub fn fmt(&self) -> String {
        let mut s = "samples/sec, opt_steps/sec, duration\n".to_string();
        s += format!(
            "{}, {}, {}\n",
            self.samples_per_sec,
            self.opt_per_sec,
            self.duration.as_secs_f32()
        )
        .as_str();
        s
    }
}