mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-12-02 12:56:49 +00:00
Fix Performance Check Tools
Signed-off-by: wuliangdong <wuliangdong1@huawei.com> Change-Id: I410d663319cfcf4c51d6c850264af16d57f4104f
This commit is contained in:
parent
32c1242829
commit
6ae1ce0208
@ -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)) {
|
||||
|
@ -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)
|
||||
|
@ -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 "
|
||||
|
Loading…
Reference in New Issue
Block a user