Procházet zdrojové kódy

feat: group reports by local date

codex/lq-token-test-init
orangels před 1 měsícem
rodič
revize
1f5bdb26f6
1 změnil soubory, kde provedl 14 přidání a 5 odebrání
  1. +14
    -5
      src/report.rs

+ 14
- 5
src/report.rs Zobrazit soubor

@@ -1,6 +1,6 @@
use crate::metrics::ErrorCount;
use anyhow::{Context, Result};
use chrono::{DateTime, Utc};
use chrono::{DateTime, Local, Utc};
use serde::Serialize;
use serde_json::Value;
use std::path::{Path, PathBuf};
@@ -234,14 +234,17 @@ fn write_report<T: Serialize>(
started_at: DateTime<Utc>,
report: &T,
) -> Result<PathBuf> {
let reports_dir = root.join("reports");
let local_started_at = started_at.with_timezone(&Local);
let reports_dir = root
.join("reports")
.join(local_started_at.format("%Y%m%d").to_string());
std::fs::create_dir_all(&reports_dir).with_context(|| {
format!(
"failed to create reports directory {}",
reports_dir.display()
)
})?;
let timestamp = started_at.format("%Y%m%dT%H%M%SZ");
let timestamp = local_started_at.format("%Y%m%dT%H%M%S%z");
let filename = format!(
"{}-{}-{}-{timestamp}.json",
sanitize_filename_component(benchmark),
@@ -296,6 +299,7 @@ mod tests {
#[test]
fn writes_benchmark_report_under_reports_dir() {
let temp_dir = tempfile::tempdir().expect("create temp dir");
let started_at = Utc.with_ymd_and_hms(2026, 5, 6, 1, 2, 3).unwrap();
let report = BenchmarkReport {
benchmark: "aime2026".to_string(),
provider: "openai".to_string(),
@@ -318,7 +322,7 @@ mod tests {
local_path: "data/benchmarks/aime2026/aime2026.jsonl".to_string(),
},
run: RunReport {
started_at: Utc.with_ymd_and_hms(2026, 5, 6, 1, 2, 3).unwrap(),
started_at,
duration_ms: 123,
concurrency: 2,
limit: Some(1),
@@ -351,7 +355,12 @@ mod tests {

let path = write_benchmark_report(temp_dir.path(), &report).expect("write report");

assert!(path.ends_with("reports/aime2026-openai-gpt-test-20260506T010203Z.json"));
let local_started_at = started_at.with_timezone(&chrono::Local);
let expected_date = local_started_at.format("%Y%m%d").to_string();
let expected_timestamp = local_started_at.format("%Y%m%dT%H%M%S%z").to_string();
assert!(path.ends_with(format!(
"reports/{expected_date}/aime2026-openai-gpt-test-{expected_timestamp}.json"
)));
assert!(path.exists());
}



Načítá se…
Zrušit
Uložit