border_async_trainer/async_trainer/
stat.rs

1use std::time::Duration;
2/// Stats of [`AsyncTrainer`](crate::AsyncTrainer)`::train()`.
3pub struct AsyncTrainStat {
4    /// The number of samples pushed to the replay buffer per second.
5    pub samples_per_sec: f32,
6
7    /// Duration of training.
8    pub duration: Duration,
9
10    /// The number of optimization steps per second.
11    pub opt_per_sec: f32,
12}
13
14impl AsyncTrainStat {
15    /// Returns a formatted string.
16    pub fn fmt(&self) -> String {
17        let mut s = "samples/sec, opt_steps/sec, duration\n".to_string();
18        s += format!(
19            "{}, {}, {}\n",
20            self.samples_per_sec,
21            self.opt_per_sec,
22            self.duration.as_secs_f32()
23        )
24        .as_str();
25        s
26    }
27}