Skip to main content

gglib_core/domain/benchmark/
run.rs

1//! Benchmark run metadata: type, lifecycle status, and the run record itself.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// Whether a benchmark run measured inference quality/speed or raw throughput.
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "snake_case")]
9pub enum BenchmarkRunType {
10    /// Prompt-comparison run: N models answer the same prompt.
11    Compare,
12    /// Performance run: `llama-bench` reports raw pp/tg tokens/sec.
13    Perf,
14    /// Tuning run: sweep sampling parameters for one model against an
15    /// agentic tool-calling task suite to find the best-scoring settings.
16    Tune,
17}
18
19/// Lifecycle state of a benchmark run.
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
21#[serde(rename_all = "snake_case")]
22pub enum BenchmarkRunStatus {
23    /// Run is currently in progress.
24    Running,
25    /// Run finished successfully.
26    Complete,
27    /// Run encountered an error or was aborted.
28    Failed,
29}
30
31/// Lightweight record grouping one or more model results under a single run.
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct BenchmarkRun {
34    /// Database ID of the run.
35    pub id: i64,
36    /// Whether this is a compare, perf, or tune run.
37    pub run_type: BenchmarkRunType,
38    /// Current lifecycle state.
39    pub status: BenchmarkRunStatus,
40    /// Ordered list of model IDs that were (or will be) benchmarked.
41    pub model_ids: Vec<i64>,
42    /// Prompt text used for compare runs (absent for perf/tune runs).
43    pub prompt_text: Option<String>,
44    /// System prompt used for compare runs.
45    pub system_prompt: Option<String>,
46    /// Serialised run configuration (`CompareConfig`, `PerfConfig`, or
47    /// `TuneConfig` JSON).
48    pub config_json: Option<String>,
49    /// Error message if the run failed.
50    pub error: Option<String>,
51    /// UTC timestamp when the run was created.
52    pub created_at: DateTime<Utc>,
53    /// UTC timestamp when the run completed or failed.
54    pub completed_at: Option<DateTime<Utc>>,
55}