From e2a065c2c62d01107a71e35a39036bb1732f3525 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:05:07 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=88=AA=E5=9B=BE=E8=80=97=E6=97=B6?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=9C=80=E5=80=BC=E3=80=81=E5=9D=87=E5=80=BC?= =?UTF-8?q?=E6=8E=92=E9=99=A4=E6=88=AA=E5=9B=BE=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E8=80=97=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Controller/AdbController.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp index 8d5b94b425..6e5b4cb885 100644 --- a/src/MaaCore/Controller/AdbController.cpp +++ b/src/MaaCore/Controller/AdbController.cpp @@ -466,7 +466,10 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect } if (m_screencap_time > 9) { // 每 10 次截图计算一次平均耗时 m_screencap_time = 0; - auto [screencap_cost_min, screencap_cost_max] = ranges::minmax(m_screencap_duration); + auto filted_duration = m_screencap_duration | views::filter([](long long num) { return num < INT_MAX; }); + // 过滤后的有效截图用时次数 + auto filted_count = m_screencap_duration.size() - ranges::count(m_screencap_duration, INT_MAX); + auto [screencap_cost_min, screencap_cost_max] = ranges::minmax(filted_duration); json::value info = json::object { { "uuid", m_uuid }, { "what", "ScreencapCost" }, @@ -474,8 +477,7 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect json::object { { "min", screencap_cost_min }, { "max", screencap_cost_max }, - { "avg", std::accumulate(m_screencap_duration.begin(), m_screencap_duration.end(), 0ll) / - m_screencap_duration.size() }, + { "avg", std::accumulate(filted_duration.begin(), filted_duration.end(), 0ll) / filted_count }, } }, }; callback(AsstMsg::ConnectionInfo, info);