From b8a30971feb93307a6e8719438f1c24655230b61 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:54:29 +0800 Subject: [PATCH] =?UTF-8?q?perf(MaaCore):=20ScreencapCost=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E5=A4=B1=E8=B4=A5=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaCore/Controller/AdbController.cpp | 29 ++++++++++++------------ 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp index fc939b705c..718d37a658 100644 --- a/src/MaaCore/Controller/AdbController.cpp +++ b/src/MaaCore/Controller/AdbController.cpp @@ -470,21 +470,20 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect m_screencap_duration | views::filter([](long long num) { return num < LLONG_MAX; }); // 过滤后的有效截图用时次数 auto filtered_count = m_screencap_duration.size() - ranges::count(m_screencap_duration, LLONG_MAX); - if (filtered_count != 0) { - auto [screencap_cost_min, screencap_cost_max] = ranges::minmax(filtered_duration); - json::value info = json::object { - { "uuid", m_uuid }, - { "what", "ScreencapCost" }, - { "details", - json::object { - { "min", screencap_cost_min }, - { "max", screencap_cost_max }, - { "avg", - std::accumulate(filtered_duration.begin(), filtered_duration.end(), 0LL) / filtered_count }, - } }, - }; - callback(AsstMsg::ConnectionInfo, info); - } + auto [screencap_cost_min, screencap_cost_max] = ranges::minmax(filtered_duration); + json::value info = json::object { + { "uuid", m_uuid }, + { "what", "ScreencapCost" }, + { "details", + json::object { { "min", screencap_cost_min }, + { "max", screencap_cost_max }, + { "avg", filtered_count > 0 ? std::accumulate(filtered_duration.begin(), + filtered_duration.end(), 0ll) / + filtered_count + : -1 }, + { "fault_times", m_screencap_duration.size() - filtered_count } } }, + }; + callback(AsstMsg::ConnectionInfo, info); } return screencap_ret; }