pub struct ExportUseCase;Expand description
Use case for exporting receipts to different formats.
Implementations§
Source§impl ExportUseCase
impl ExportUseCase
Sourcepub fn export_run(
receipt: &RunReceipt,
format: ExportFormat,
) -> Result<String, Error>
pub fn export_run( receipt: &RunReceipt, format: ExportFormat, ) -> Result<String, Error>
Export a RunReceipt to the specified format.
let receipt = RunReceipt {
schema: RUN_SCHEMA_V1.to_string(),
tool: ToolInfo { name: "perfgate".into(), version: "0.1.0".into() },
run: RunMeta {
id: "r1".into(),
started_at: "2024-01-01T00:00:00Z".into(),
ended_at: "2024-01-01T00:00:01Z".into(),
host: HostInfo { os: "linux".into(), arch: "x86_64".into(),
cpu_count: None, memory_bytes: None, hostname_hash: None },
},
bench: BenchMeta {
name: "bench".into(), cwd: None,
command: vec!["echo".into()], repeat: 1, warmup: 0,
work_units: None, timeout_ms: None,
},
samples: vec![Sample {
wall_ms: 42, exit_code: 0, warmup: false, timed_out: false,
cpu_ms: None, page_faults: None, ctx_switches: None,
max_rss_kb: None, io_read_bytes: None, io_write_bytes: None,
network_packets: None, energy_uj: None, binary_bytes: None, stdout: None, stderr: None,
}],
stats: Stats {
wall_ms: U64Summary::new(42, 42, 42 ),
cpu_ms: None, page_faults: None, ctx_switches: None,
max_rss_kb: None, io_read_bytes: None, io_write_bytes: None,
network_packets: None, energy_uj: None, binary_bytes: None, throughput_per_s: None,
},
};
let csv = ExportUseCase::export_run(&receipt, ExportFormat::Csv).unwrap();
assert!(csv.contains("bench"));
assert!(csv.contains("42"));Sourcepub fn export_compare(
receipt: &CompareReceipt,
format: ExportFormat,
) -> Result<String, Error>
pub fn export_compare( receipt: &CompareReceipt, format: ExportFormat, ) -> Result<String, Error>
Export a CompareReceipt to the specified format.
let receipt = CompareReceipt {
schema: COMPARE_SCHEMA_V1.to_string(),
tool: ToolInfo { name: "perfgate".into(), version: "0.1.0".into() },
bench: BenchMeta {
name: "bench".into(), cwd: None,
command: vec!["echo".into()], repeat: 1, warmup: 0,
work_units: None, timeout_ms: None,
},
baseline_ref: CompareRef { path: None, run_id: None },
current_ref: CompareRef { path: None, run_id: None },
budgets: BTreeMap::new(),
deltas: BTreeMap::from([(Metric::WallMs, Delta {
baseline: 100.0, current: 110.0, ratio: 1.1, pct: 0.1, regression: 0.1,
cv: None, noise_threshold: None,
statistic: MetricStatistic::Median, significance: None, status: MetricStatus::Pass
})]),
verdict: Verdict {
status: VerdictStatus::Pass,
counts: VerdictCounts { pass: 1, warn: 0, fail: 0, skip: 0 },
reasons: vec![],
},
};
let csv = ExportUseCase::export_compare(&receipt, ExportFormat::Csv).unwrap();
assert!(csv.contains("wall_ms"));
assert!(csv.contains("100"));Auto Trait Implementations§
impl Freeze for ExportUseCase
impl RefUnwindSafe for ExportUseCase
impl Send for ExportUseCase
impl Sync for ExportUseCase
impl Unpin for ExportUseCase
impl UnsafeUnpin for ExportUseCase
impl UnwindSafe for ExportUseCase
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.