use std::time::SystemTime;
#[derive(Debug, Clone)]
pub struct PlotData {
pub operation_names: Vec<String>,
pub avg_times: Vec<f64>,
pub throughputs: Vec<f64>,
pub memory_usage: Vec<f64>,
pub timestamps: Vec<SystemTime>,
}
impl PlotData {
pub fn new() -> Self {
Self {
operation_names: Vec::new(),
avg_times: Vec::new(),
throughputs: Vec::new(),
memory_usage: Vec::new(),
timestamps: Vec::new(),
}
}
pub fn add_point(&mut self, operation: String, time_ms: f64, throughput: f64, memory: f64) {
self.operation_names.push(operation);
self.avg_times.push(time_ms);
self.throughputs.push(throughput);
self.memory_usage.push(memory);
self.timestamps.push(SystemTime::now());
}
pub fn time_series_data(&self) -> Vec<(SystemTime, f64, f64, f64)> {
self.timestamps
.iter()
.zip(&self.avg_times)
.zip(&self.throughputs)
.zip(&self.memory_usage)
.map(|(((time, avg_time), throughput), memory)| {
(*time, *avg_time, *throughput, *memory)
})
.collect()
}
}
impl Default for PlotData {
fn default() -> Self {
Self::new()
}
}