From 7f095c3dc72187d1915bd639969f5d54e233bd2e Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Thu, 1 Jan 2026 20:01:58 -0600 Subject: [PATCH] update p99 --- ErsatzTV.Infrastructure/ScanProfiler.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ErsatzTV.Infrastructure/ScanProfiler.cs b/ErsatzTV.Infrastructure/ScanProfiler.cs index 3ec3ecfaf..8b02c7ba9 100644 --- a/ErsatzTV.Infrastructure/ScanProfiler.cs +++ b/ErsatzTV.Infrastructure/ScanProfiler.cs @@ -35,7 +35,10 @@ public static class ScanProfiler double avg = times.Average(); long min = times.Min(); long max = times.Max(); - long p99 = times[(int)(times.Count * 0.99)]; + int n = times.Count; + int idx = (int)Math.Ceiling(0.99 * n) - 1; + idx = Math.Clamp(idx, 0, n - 1); + long p99 = times[idx]; double totalSec = times.Sum() / 1000.0; sb.AppendLine(FormattableString.Invariant($"{key,-25} | {times.Count,-6} | {avg,-8:F1} | {min,-6} | {max,-6} | {p99,-6} | {totalSec,-8:F2}"));