(records: &[PatchRecord])
| 261 | } |
| 262 | |
| 263 | fn build_model_performance(records: &[PatchRecord]) -> Vec<ModelPerformance> { |
| 264 | let mut grouped: HashMap<String, (usize, usize)> = HashMap::new(); |
| 265 | for r in records { |
| 266 | let entry = grouped.entry(r.model_used.clone()).or_insert((0, 0)); |
| 267 | entry.0 += 1; |
| 268 | if is_success(r) { |
| 269 | entry.1 += 1; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | let mut out: Vec<ModelPerformance> = grouped |
| 274 | .into_iter() |
| 275 | .map(|(model, (total, success))| ModelPerformance { |
| 276 | model, |
| 277 | success_rate: if total == 0 { |
| 278 | 0.0 |
| 279 | } else { |
| 280 | success as f32 / total as f32 |
| 281 | }, |
| 282 | avg_latency_ms: 0, |
| 283 | avg_cost: 0.0, |
| 284 | }) |
| 285 | .collect(); |
| 286 | out.sort_by(|a, b| a.model.cmp(&b.model)); |
| 287 | out |
| 288 | } |
| 289 | |
| 290 | #[cfg(test)] |
| 291 | mod tests { |
no test coverage detected
searching dependent graphs…