Skip to main content

Crate perfgate_export

Crate perfgate_export 

Source
Expand description

Export formats for perfgate benchmarks.

This crate provides functionality for exporting run and compare receipts to various formats suitable for trend analysis and time-series ingestion.

§Supported Formats

  • CSV: RFC 4180 compliant CSV with header row
  • JSONL: JSON Lines format (one JSON object per line)
  • HTML: HTML summary table
  • Prometheus: Prometheus text exposition format
  • JUnit: JUnit XML format (for legacy CI/Jenkins)

§Example

use perfgate_export::{ExportFormat, ExportUseCase};
use perfgate_types::*;
use std::collections::BTreeMap;

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,
    },
};

// Export a run receipt to CSV
let csv = ExportUseCase::export_run(&receipt, ExportFormat::Csv).unwrap();
assert!(csv.contains("bench"));

Structs§

CompareExportRow
Row structure for CompareReceipt export.
ExportUseCase
Use case for exporting receipts to different formats.
RunExportRow
Row structure for RunReceipt export.

Enums§

ExportFormat
Supported export formats.

Functions§

csv_escape
Escape a string for CSV per RFC 4180. If the string contains comma, double quote, or newline, wrap in quotes and escape quotes.