-
Notifications
You must be signed in to change notification settings - Fork 0
Performance zh TW
SpaceSquare edited this page Aug 3, 2026
·
1 revision
English: Performance
cv2.matchTemplate(本身已是原生 OpenCV 程式碼)主宰了掃描的耗時,而且它執行運算期間會釋放 Python 的 GIL——所以把多條規則的掃描工作分散到執行緒池,不用寫任何 C++ 就能拿到真正的多核心加速(實測 4–16 個 workers 約有 ~3–4.6 倍加速)。用 --max-workers N 選擇性開啟:
python -m core.run rules.json --max-workers 4
python -m core.server --max-workers 4GUI 伺服器預設是 min(4, CPU 核心數);命令列版本預設維持 1(循序),保持行為簡單、可預期。只有規則數量較多、或 ROI 較大時才有感——只有一兩條小規則的話沒什麼好平行的。
細節請見 repo 裡的 benchmarks/,裡面也說明了為什麼手寫 C++ 模組不是這裡該做的事。