pub struct ResultWriter { /* private fields */ }Expand description
Writes results.json and summary.md to an output directory.
Files are written atomically by flushing to a .tmp sibling file and then
renaming, so a concurrent SIGINT cannot leave a half-written JSON file.
§Examples
use zeph_bench::{ResultWriter, BenchRun, RunStatus, Aggregate};
let writer = ResultWriter::new("/tmp/my-bench-run").unwrap();
println!("results at {}", writer.results_path().display());Implementations§
Source§impl ResultWriter
impl ResultWriter
Sourcepub fn new(output_dir: impl Into<PathBuf>) -> Result<Self, BenchError>
pub fn new(output_dir: impl Into<PathBuf>) -> Result<Self, BenchError>
Create a writer targeting output_dir.
The directory is created automatically (single level) if it does not exist.
§Errors
Returns BenchError::Io if the directory cannot be created.
Sourcepub fn results_path(&self) -> PathBuf
pub fn results_path(&self) -> PathBuf
Absolute path of results.json inside the output directory.
§Examples
use std::path::Path;
use zeph_bench::ResultWriter;
let dir = tempfile::tempdir().unwrap();
let writer = ResultWriter::new(dir.path()).unwrap();
assert!(writer.results_path().ends_with("results.json"));Sourcepub fn summary_path(&self) -> PathBuf
pub fn summary_path(&self) -> PathBuf
Absolute path of summary.md inside the output directory.
§Examples
use zeph_bench::ResultWriter;
let dir = tempfile::tempdir().unwrap();
let writer = ResultWriter::new(dir.path()).unwrap();
assert!(writer.summary_path().ends_with("summary.md"));Sourcepub fn load_existing(&self) -> Result<Option<BenchRun>, BenchError>
pub fn load_existing(&self) -> Result<Option<BenchRun>, BenchError>
Load an existing results.json for resume.
Returns None when the file does not exist (treat as fresh run).
§Errors
Returns BenchError::Io on read failure, or BenchError::InvalidFormat if
the file exists but cannot be deserialized.
Sourcepub fn write(&self, run: &BenchRun) -> Result<(), BenchError>
pub fn write(&self, run: &BenchRun) -> Result<(), BenchError>
Write run to results.json and summary.md atomically (best-effort).
§Errors
Returns BenchError on serialization or I/O failure.
Auto Trait Implementations§
impl Freeze for ResultWriter
impl RefUnwindSafe for ResultWriter
impl Send for ResultWriter
impl Sync for ResultWriter
impl Unpin for ResultWriter
impl UnsafeUnpin for ResultWriter
impl UnwindSafe for ResultWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request