Added total camera fps, total processed fps, and total skipped fps to stats api (#19469)

Co-authored-by: Mark Francis <markfrancisonly@gmail.com>
This commit is contained in:
markfrancisonly 2025-08-12 12:49:53 -04:00 committed by GitHub
parent 2a7525ef20
commit c52c03ddfd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 13 deletions

View File

@ -268,10 +268,13 @@ def stats_snapshot(
camera_metrics = stats_tracking["camera_metrics"]
stats: dict[str, Any] = {}
total_detection_fps = 0
total_camera_fps = total_process_fps = total_skipped_fps = total_detection_fps = 0
stats["cameras"] = {}
for name, camera_stats in camera_metrics.items():
total_camera_fps += camera_stats.camera_fps.value
total_process_fps += camera_stats.process_fps.value
total_skipped_fps += camera_stats.skipped_fps.value
total_detection_fps += camera_stats.detection_fps.value
pid = camera_stats.process_pid.value if camera_stats.process_pid.value else None
ffmpeg_pid = camera_stats.ffmpeg_pid.value if camera_stats.ffmpeg_pid else None
@ -305,6 +308,9 @@ def stats_snapshot(
# from mypy 0.981 onwards
"pid": pid,
}
stats["camera_fps"] = round(total_camera_fps, 2)
stats["process_fps"] = round(total_process_fps, 2)
stats["skipped_fps"] = round(total_skipped_fps, 2)
stats["detection_fps"] = round(total_detection_fps, 2)
stats["embeddings"] = {}

View File

@ -45,6 +45,9 @@ class BaseTestHttp(unittest.TestCase):
},
}
self.test_stats = {
"camera_fps": 5.0,
"process_fps": 5.0,
"skipped_fps": 0.0,
"detection_fps": 13.7,
"detectors": {
"cpu1": {

View File

@ -49,6 +49,9 @@ class TestHttp(unittest.TestCase):
},
}
self.test_stats = {
"camera_fps": 5.0,
"process_fps": 5.0,
"skipped_fps": 0.0,
"detection_fps": 13.7,
"detectors": {
"cpu1": {

View File

@ -7,6 +7,9 @@ export interface FrigateStats {
npu_usages?: { [npuKey: string]: NpuStats };
processes: { [processKey: string]: ExtraProcessStats };
service: ServiceStats;
camera_fps: number;
process_fps: number;
skipped_fps: number;
detection_fps: number;
}

View File

@ -97,14 +97,9 @@ export default function CameraMetrics({
return;
}
let frames = 0;
Object.values(stats.cameras).forEach(
(camStat) => (frames += camStat.camera_fps),
);
series["overall_fps"].data.push({
x: statsIdx,
y: Math.round(frames),
y: stats.camera_fps,
});
series["overall_dps"].data.push({
@ -112,14 +107,9 @@ export default function CameraMetrics({
y: stats.detection_fps,
});
let skipped = 0;
Object.values(stats.cameras).forEach(
(camStat) => (skipped += camStat.skipped_fps),
);
series["overall_skipped_dps"].data.push({
x: statsIdx,
y: skipped,
y: stats.skipped_fps,
});
});
return Object.values(series);