45 lines
1015 B
Rust
45 lines
1015 B
Rust
use anyhow::Result;
|
|
use serde::Serialize;
|
|
use std::path::Path;
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct PerRequestRow {
|
|
pub req_id: u64,
|
|
pub arrival: f64,
|
|
pub ttft: f64,
|
|
pub e2e: f64,
|
|
pub bucket: u32,
|
|
pub instance: u32,
|
|
pub length_bucket_match: bool,
|
|
pub total_blocks: u32,
|
|
pub l0_hit_blocks: u32,
|
|
pub l1_hit_blocks: u32,
|
|
pub remote_hit_blocks: u32,
|
|
pub miss_blocks: u32,
|
|
pub rdma_bytes: u64,
|
|
pub pcie_bytes: u64,
|
|
pub probe_overhead_s: f64,
|
|
}
|
|
|
|
pub struct PerRequestWriter {
|
|
inner: csv::Writer<std::fs::File>,
|
|
}
|
|
|
|
impl PerRequestWriter {
|
|
pub fn create<P: AsRef<Path>>(path: P) -> Result<Self> {
|
|
let f = std::fs::File::create(path)?;
|
|
let inner = csv::Writer::from_writer(f);
|
|
Ok(Self { inner })
|
|
}
|
|
|
|
pub fn write(&mut self, row: &PerRequestRow) -> Result<()> {
|
|
self.inner.serialize(row)?;
|
|
Ok(())
|
|
}
|
|
|
|
pub fn finish(mut self) -> Result<()> {
|
|
self.inner.flush()?;
|
|
Ok(())
|
|
}
|
|
}
|