Expand description
Benchmark common utilities — PCI bus ID normalization, timing, result structs with JSON serialization, and timestamped logging.
Ports the core infrastructure from scripts/lib/benchmark_common.sh:
- PCI bus ID normalization (
0000:01:00.0→01:00.0) - Benchmark timing utilities (elapsed calculation, formatting)
BenchmarkResultstruct with JSON serialization compatible withbenchmark_logs.rsparsing- Timestamped logging with
[YYYY-MM-DD HH:MM:SS]prefix - Tee-style logging to stderr + optional file output
§Validation Assertions
- VAL-INFRA-013: PCI bus normalization, timing utilities, result struct with JSON serialization
- VAL-INFRA-014: Timestamped logging
[YYYY-MM-DD HH:MM:SS]prefix, supports stderr + file output
Structs§
- Bench
Logger - Benchmark logger that writes timestamped lines to stderr and optionally to a log file (tee behavior).
- Bench
Timer - A simple stopwatch for benchmark timing.
- Benchmark
Result - A single benchmark measurement result.
- Benchmark
Results - A collection of benchmark results, compatible with the JSON schema used
by
benchmark_logs.rs.
Functions§
- format_
elapsed - Format a
Durationas a human-readable string. - format_
timestamp_ prefix - Format a timestamp string for use in log lines.
- is_
dry_ run - Check if dry-run mode is enabled via environment variable.
- normalize_
pci_ bus_ id - Normalize a PCI bus ID string.
- now_
timestamp - Get the current timestamp in
YYYY-MM-DD HH:MM:SSformat. - resolve_
log_ dir - Resolve the benchmark log directory.