(&self)
| 313 | } |
| 314 | |
| 315 | pub fn summary(&self) -> String { |
| 316 | if !self.enabled { |
| 317 | return String::from("profiler: disabled\n"); |
| 318 | } |
| 319 | let mut entries: Vec<(&&str, &RollingStats)> = self.rolling.iter() |
| 320 | .map(|(k, v)| (k, v)) |
| 321 | .collect(); |
| 322 | entries.sort_by(|a, b| b.1.avg_cpu().partial_cmp(&a.1.avg_cpu()).unwrap_or(std::cmp::Ordering::Equal)); |
| 323 | |
| 324 | let mut out = String::new(); |
| 325 | out.push_str(&format!( |
| 326 | "profiler (avg over last {} frames, gpu={}):\n", |
| 327 | ROLLING_FRAMES.min(entries.first().map(|(_,s)| s.filled).unwrap_or(0)), |
| 328 | if self.gpu_enabled { "yes" } else { "no" }, |
| 329 | )); |
| 330 | out.push_str(" phase cpu us gpu us\n"); |
| 331 | for (label, stats) in entries { |
| 332 | let gpu = stats.avg_gpu().map(|v| format!("{:>9.1}", v)).unwrap_or_else(|| " -".to_string()); |
| 333 | out.push_str(&format!(" {:<28} {:>9.1} {}\n", label, stats.avg_cpu(), gpu)); |
| 334 | } |
| 335 | out |
| 336 | } |
| 337 | |
| 338 | /// Average total CPU frame time across the rolling window (sum of |
| 339 | /// all phases). Useful for a single headline number. |
no test coverage detected