Fix Performance Check Tools

Signed-off-by: wuliangdong <wuliangdong1@huawei.com>
Change-Id: I410d663319cfcf4c51d6c850264af16d57f4104f
This commit is contained in:
wuliangdong 2024-05-04 06:18:59 +00:00
parent 32c1242829
commit 6ae1ce0208
3 changed files with 19 additions and 6 deletions

View File

@ -20,7 +20,7 @@ declare_args() {
fusion_drag_enable_monitor = true
fusion_drag_enable_interceptor = false
fusion_drag_enable_animation = false
fusion_performance_check = false
fusion_performance_check = true
device_status_sensor_enable = true
if (defined(global_parts_info)) {
if (!defined(global_parts_info.sensors_sensor)) {

View File

@ -15,6 +15,10 @@
#include "dsoftbus_adapter_impl.h"
#ifdef ENABLE_PERFORMANCE_CHECK
#include <chrono>
#endif // ENABLE_PERFORMANCE_CHECK
#include <netinet/in.h>
#include <netinet/tcp.h>
@ -106,7 +110,16 @@ int32_t DSoftbusAdapterImpl::OpenSession(const std::string &networkId)
{
CALL_DEBUG_ENTER;
std::lock_guard guard(lock_);
return OpenSessionLocked(networkId);
#ifdef ENABLE_PERFORMANCE_CHECK
auto startStamp = std::chrono::steady_clock::now();
#endif // ENABLE_PERFORMANCE_CHECK
int32_t ret = OpenSessionLocked(networkId);
#ifdef ENABLE_PERFORMANCE_CHECK
auto openSessionDuration = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - startStamp).count();
FI_HILOGI("[PERF] OpenSessionLocked ret:%{public}d, elapsed: %{public}lld ms", ret, openSessionDuration);
#endif // ENABLE_PERFORMANCE_CHECK
return ret;
}
void DSoftbusAdapterImpl::CloseSession(const std::string &networkId)

View File

@ -535,10 +535,10 @@ void CooperateClient::DumpPerformanceInfo()
performanceInfo_.failNum = firstSuccessIndex;
performanceInfo_.failBeforeSuccess = firstSuccessIndex;
performanceInfo_.firstSuccessDuration = performanceInfo_.durationList[firstSuccessIndex];
int32_t successDurationSum = performanceInfo_.firstSuccessDuration;
int32_t successDurationSumWithoutFirst { 0 };
for (int32_t i = firstSuccessIndex + 1; i < durationLen; i++) {
if (performanceInfo_.durationList[i] != FAILURE_DURATION) {
successDurationSum += performanceInfo_.durationList[i];
successDurationSumWithoutFirst += performanceInfo_.durationList[i];
performanceInfo_.minDuration = std::min(performanceInfo_.durationList[i], performanceInfo_.minDuration);
performanceInfo_.maxDuration = std::max(performanceInfo_.durationList[i], performanceInfo_.maxDuration);
performanceInfo_.successNum += 1;
@ -551,8 +551,8 @@ void CooperateClient::DumpPerformanceInfo()
performanceInfo_.successRate = (static_cast<float>(performanceInfo_.successNum) * PERCENTAGE) /
validActivateNum;
}
if (performanceInfo_.successNum > 0) {
performanceInfo_.averageDuration = successDurationSum / performanceInfo_.successNum;
if (int32_t successNumWithoutFirst = performanceInfo_.successNum - 1; successNumWithoutFirst > 0) {
performanceInfo_.averageDuration = successDurationSumWithoutFirst / successNumWithoutFirst;
}
FI_HILOGI("[PERF] performanceInfo:"
"activateNum:%{public}d successNum:%{public}d failNum:%{public}d successRate:%{public}.2f "