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>
pub fn export_run(receipt: &RunReceipt, format: ExportFormat) -> Result<String>
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>
pub fn export_compare( receipt: &CompareReceipt, format: ExportFormat, ) -> Result<String>
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