gglib_core/domain/benchmark/summary.rs
1//! Denormalised per-model benchmark summary.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// Denormalised benchmark summary for a single model.
7///
8/// Upserted in the same transaction as each new result so that the model list
9/// query can LEFT JOIN this table and show speed badges without extra round-trips.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11#[cfg_attr(feature = "ts-bindings", derive(ts_rs::TS), ts(export))]
12pub struct ModelBenchmarkSummary {
13 /// Foreign key → `models.id`.
14 #[cfg_attr(feature = "ts-bindings", ts(type = "number"))]
15 pub model_id: i64,
16 /// Best token-generation throughput across all perf runs.
17 pub best_tg_tps: Option<f64>,
18 /// Best prompt-processing throughput across all perf runs.
19 pub best_pp_tps: Option<f64>,
20 /// Token-generation throughput from the most recent perf run.
21 pub latest_tg_tps: Option<f64>,
22 /// Prompt-processing throughput from the most recent perf run.
23 pub latest_pp_tps: Option<f64>,
24 /// Backend reported by the most recent perf run.
25 pub latest_backend: Option<String>,
26 /// Total number of perf runs recorded for this model.
27 #[cfg_attr(feature = "ts-bindings", ts(type = "number"))]
28 pub perf_run_count: i64,
29 /// Total number of compare runs recorded for this model.
30 #[cfg_attr(feature = "ts-bindings", ts(type = "number"))]
31 pub compare_run_count: i64,
32 /// UTC timestamp of the most recent benchmark (either type).
33 pub last_benchmarked_at: DateTime<Utc>,
34 /// UTC timestamp of the last summary update.
35 pub updated_at: DateTime<Utc>,
36}