frigate/frigate/test
Daniel d982b3a782
Some checks failed
CI / AMD64 Build (push) Has been cancelled
CI / ARM Build (push) Has been cancelled
CI / Jetson Jetpack 6 (push) Has been cancelled
CI / AMD64 Extra Build (push) Has been cancelled
CI / ARM Extra Build (push) Has been cancelled
CI / Synaptics Build (push) Has been cancelled
CI / Assemble and push default build (push) Has been cancelled
perf(util): use monotonic clock and bounded deque in EventsPerSecond (#23520)
* perf(util): use monotonic clock and bounded deque in EventsPerSecond

EventsPerSecond is updated on every captured frame, every detection and
every processed frame across all cameras and detectors. The previous
implementation derived timestamps from datetime.now().timestamp() (wall
clock), so an NTP or manual clock adjustment could skew the rolling-window
expiry; it also stored timestamps in a list and expired them with
del self._timestamps[0] (O(n) per removal) plus a periodic slice-copy to
cap growth.

Switch to time.monotonic() for the interval math (correct by construction
and immune to wall-clock jumps) and a collections.deque(maxlen=...) so
expiry is O(1) (popleft) and retention is bounded automatically. This
mirrors the deque-based expiry already used in video/ffmpeg.py and
watchdog.py. Observable output is unchanged.

Adds frigate/test/test_builtin.py covering rate calculation, window
expiry and the memory bound.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* test: drop test_timestamps_are_memory_bounded

It only asserted that deque(maxlen=) caps length, which is stdlib behavior
rather than something this change needs to verify.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 07:38:41 -06:00
..
http_api Add recording keyframe analysis to camera probe dialog (#23453) 2026-06-11 14:16:41 -06:00
__init__.py app container and config schema 2021-01-26 21:40:33 -06:00
const.py Work through most of the cspell warnings in python (#13794) 2024-09-17 10:41:46 -05:00
test_birdseye.py Write a low resolution low fps stream from decoded frames (#8673) 2024-01-31 12:56:11 +00:00
test_builtin.py perf(util): use monotonic clock and bounded deque in EventsPerSecond (#23520) 2026-06-21 07:38:41 -06:00
test_camera_maintainer.py Debug replay resolution (#23287) 2026-05-22 08:39:52 -06:00
test_camera_pw.py fix typos (#9895) 2024-02-17 16:01:50 -06:00
test_chat_find_similar_objects.py Camera access fixes (#22987) 2026-04-23 12:27:49 -06:00
test_config.py Add attributes to UI filters list (#23250) 2026-05-19 08:31:50 -06:00
test_copy_yuv_to_position.py Cleanup and organize utils (#7033) 2023-07-06 09:28:50 -05:00
test_debug_replay_job.py Debug replay fixes (#23270) 2026-05-20 16:37:02 -05:00
test_debug_replay.py Miscellaneous fixes (#23238) 2026-05-18 22:52:40 -05:00
test_deferred_processor.py Add deferred real-time processor for enrichments (#22880) 2026-04-14 21:39:44 -06:00
test_dispatcher_runtime_state.py Restore runtime state on startup (#23326) 2026-05-27 12:03:09 -06:00
test_env.py Improve environment var handling (#22796) 2026-04-07 07:16:02 -06:00
test_export_progress.py Use Job infrastructure for Debug Replay (#23099) 2026-05-03 14:54:20 -06:00
test_export.py Replace export ffmpeg argument blocklist with a structural allowlist (#23478) 2026-06-13 16:43:22 -06:00
test_ffmpeg_presets.py Update ffmpeg (#22548) 2026-03-20 08:50:58 -05:00
test_ffmpeg_progress.py Use Job infrastructure for Debug Replay (#23099) 2026-05-03 14:54:20 -06:00
test_file.py Enable event snapshot API to honour query params after event ends (#22375) 2026-03-22 13:33:04 -06:00
test_go2rtc_stream_auth.py Miscellaneous fixes (#23513) 2026-06-19 10:10:22 -06:00
test_gpu_stats.py Improve Intel Stats (#23190) 2026-05-13 15:12:48 -06:00
test_keyframe_analysis.py Add recording keyframe analysis to camera probe dialog (#23453) 2026-06-11 14:16:41 -06:00
test_maintainer.py Miscellaneous fixes (#22913) 2026-04-18 07:10:50 -06:00
test_media_auth.py Miscellaneous fixes (#23238) 2026-05-18 22:52:40 -05:00
test_motion_detector.py Skip motion threshold configuration (#22255) 2026-03-05 18:20:03 -06:00
test_motion_search_batch.py Refactor motion search (#23378) 2026-06-01 12:08:46 -05:00
test_motion_search_decode.py Refactor motion search (#23378) 2026-06-01 12:08:46 -05:00
test_motion_search_spatial.py Refactor motion search (#23378) 2026-06-01 12:08:46 -05:00
test_norfair_distance.py guard norfair distance against non-finite and zero-area boxes that could crash autotracking cameras (#23475) 2026-06-13 16:23:30 -05:00
test_obects.py Various fixes (#14410) 2024-10-17 11:02:27 -05:00
test_object_detector.py Improve async object detector support (#17712) 2025-04-15 08:55:38 -05:00
test_onvif_probe.py Support onvif PasswordText cameras in the add camera wizard (#23365) 2026-05-31 08:20:09 -06:00
test_output_ws_auth.py Camera access fixes (#22987) 2026-04-23 12:27:49 -06:00
test_preview_loader.py Offline preview image (#21752) 2026-02-26 21:27:56 -07:00
test_profiles.py Miscellaneous fixes (#23373) 2026-06-01 13:55:52 -06:00
test_proxy_auth.py Various Tweaks (#22609) 2026-03-24 13:53:39 -06:00
test_record_retention.py Improve recording retention logic (#20506) 2025-10-15 11:09:28 -06:00
test_reduce_boxes.py Smarter Regions (#8194) 2023-10-18 18:21:52 -05:00
test_runtime_state.py Restore runtime state on startup (#23326) 2026-05-27 12:03:09 -06:00
test_shared_memory_frame_manager.py Debug replay resolution (#23287) 2026-05-22 08:39:52 -06:00
test_storage.py Pull count of detection events by label into prometheus metrics (#20119) 2025-09-19 06:27:20 -06:00
test_video.py Merge remote-tracking branch 'origin/master' into dev 2024-02-14 18:20:55 -06:00
test_webpush_camera_monitoring.py Camera access fixes (#22987) 2026-04-23 12:27:49 -06:00
test_ws_auth.py limit access to admin-only websocket topics for viewer users (#22710) 2026-03-31 08:51:55 -05:00
test_ws_outbound_filter.py Filter outbound websocket broadcasts by per-recipient camera access (#23256) 2026-05-19 14:51:16 -05:00
test_yuv_region_2_rgb.py Cleanup and organize utils (#7033) 2023-07-06 09:28:50 -05:00