diff --git a/host/smartperf/client/client_command/ByTrace.cpp b/host/smartperf/client/client_command/ByTrace.cpp index c9bb28462..afe763f9b 100644 --- a/host/smartperf/client/client_command/ByTrace.cpp +++ b/host/smartperf/client/client_command/ByTrace.cpp @@ -33,7 +33,6 @@ void ByTrace::SetTraceConfig(int mSum, int mInterval, long long mThreshold, int } void ByTrace::ThreadGetTrace() const { - isTaskCompleted = true; std::string result; std::string cmdString; if (SPUtils::IsHmKernel()) { @@ -48,7 +47,6 @@ void ByTrace::ThreadGetTrace() const SPUtils::LoadCmd(traceCmdExe, result); std::cout << "TRACE threadGetTrace >> CMD >>" << traceCmdExe << std::endl; LOGI("TRACE threadGetTrace CMD(%s)", traceCmdExe.c_str()); - isTaskCompleted = false; } TraceStatus ByTrace::CheckFpsJitters(std::vector jitters, int cfps) const { @@ -74,13 +72,7 @@ TraceStatus ByTrace::CheckFpsJitters(std::vector jitters, int cfps) c } void ByTrace::TriggerCatch(long long curTime) const { - int oneHundred = 100; - if ((curTime - lastTriggerTime) / 1e3 > interval) { - if (isTaskCompleted) { - while (isTaskCompleted) { - std::this_thread::sleep_for(std::chrono::milliseconds(oneHundred)); - } - } + if ((curTime - lastTriggerTime) / 1e3 > interval && !CheckHitraceId()) { std::thread tStart(&ByTrace::ThreadGetTrace, this); currentTrigger = 1; lastTriggerTime = curTime; @@ -88,5 +80,18 @@ void ByTrace::TriggerCatch(long long curTime) const tStart.detach(); } } + +bool ByTrace::CheckHitraceId() const +{ + std::string result; + SPUtils::LoadCmd("ps -ef |grep hitrace |grep -v grep", result); + if (result.empty()) { + return false; + } + if (result.find("-t") != std::string::npos) { + return true; + } + return false; +} } } diff --git a/host/smartperf/client/client_command/FPS.cpp b/host/smartperf/client/client_command/FPS.cpp index 569df068d..5ebc4223d 100644 --- a/host/smartperf/client/client_command/FPS.cpp +++ b/host/smartperf/client/client_command/FPS.cpp @@ -41,7 +41,13 @@ std::map FPS::ItemData() fpsInfoResult = GetFpsInfo(); prevResultFpsInfo = fpsInfoResult; } - result["refreshrate"] = GetScreenInfo(); + if (screen == "0") { + result["refreshrate"] = GetScreenInfo(); + screen = GetScreenInfo(); + } else { + result["refreshrate"] = screen; + screen = GetScreenInfo(); + } if (processFlag) { result["fps"] = "NA"; result["fpsJitters"] = "NA"; diff --git a/host/smartperf/client/client_command/GpuCounter.cpp b/host/smartperf/client/client_command/GpuCounter.cpp index 11cdc857d..1b01b5c97 100644 --- a/host/smartperf/client/client_command/GpuCounter.cpp +++ b/host/smartperf/client/client_command/GpuCounter.cpp @@ -286,7 +286,7 @@ long long GpuCounter::GetCounterDuration() bool startFlag = false; long long ret = -1; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(constConfigFile.c_str(), realPath) == nullptr)) { + if ((realpath(constConfigFile.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return 0; } diff --git a/host/smartperf/client/client_command/include/ByTrace.h b/host/smartperf/client/client_command/include/ByTrace.h index 43791da65..f5c8ada2c 100644 --- a/host/smartperf/client/client_command/include/ByTrace.h +++ b/host/smartperf/client/client_command/include/ByTrace.h @@ -32,6 +32,7 @@ public: TraceStatus CheckFpsJitters(std::vector jitters, int cfps) const; // 触发trace void TriggerCatch(long long curTime) const; + bool CheckHitraceId() const; private: ByTrace() {}; @@ -54,7 +55,6 @@ private: mutable int lowfps = -1; // 前2秒采的不准 mutable int times = 0; - mutable bool isTaskCompleted = false; }; } } diff --git a/host/smartperf/client/client_command/include/FPS.h b/host/smartperf/client/client_command/include/FPS.h index 89a24d6ff..a757e0918 100644 --- a/host/smartperf/client/client_command/include/FPS.h +++ b/host/smartperf/client/client_command/include/FPS.h @@ -102,6 +102,7 @@ private: int fifty = 50; FpsCurrentFpsTime ffTime; bool processFlag = false; + std::string screen = "0"; }; } } diff --git a/host/smartperf/client/client_command/include/sp_csv_util.h b/host/smartperf/client/client_command/include/sp_csv_util.h index ee9ba5494..3c2a684ba 100644 --- a/host/smartperf/client/client_command/include/sp_csv_util.h +++ b/host/smartperf/client/client_command/include/sp_csv_util.h @@ -31,7 +31,7 @@ public: { std::ofstream outFile; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(path.c_str(), realPath) == nullptr)) { + if ((realpath(path.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return; } @@ -60,7 +60,7 @@ public: { std::ofstream outFile; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(path.c_str(), realPath) == nullptr)) { + if ((realpath(path.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return; } diff --git a/host/smartperf/client/client_command/parse_click_complete_trace.cpp b/host/smartperf/client/client_command/parse_click_complete_trace.cpp index 58d8855cb..3b40bbffd 100644 --- a/host/smartperf/client/client_command/parse_click_complete_trace.cpp +++ b/host/smartperf/client/client_command/parse_click_complete_trace.cpp @@ -29,7 +29,7 @@ double ParseClickCompleteTrace::ParseCompleteTrace(std::string fileNamePath) { int conversion = 1000; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(fileNamePath.c_str(), realPath) == nullptr)) { + if ((realpath(fileNamePath.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return 0; } diff --git a/host/smartperf/client/client_command/parse_click_response_trace.cpp b/host/smartperf/client/client_command/parse_click_response_trace.cpp index 1ab538a36..17a0688c7 100644 --- a/host/smartperf/client/client_command/parse_click_response_trace.cpp +++ b/host/smartperf/client/client_command/parse_click_response_trace.cpp @@ -29,7 +29,7 @@ double ParseClickResponseTrace::ParseResponseTrace(std::string fileNamePath) { int conversion = 1000; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(fileNamePath.c_str(), realPath) == nullptr)) { + if ((realpath(fileNamePath.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return 0; } diff --git a/host/smartperf/client/client_command/parse_page_fps_trace.cpp b/host/smartperf/client/client_command/parse_page_fps_trace.cpp index a06c6d8f9..27bbfd578 100644 --- a/host/smartperf/client/client_command/parse_page_fps_trace.cpp +++ b/host/smartperf/client/client_command/parse_page_fps_trace.cpp @@ -24,7 +24,7 @@ double ParsePageFpsTrace::PageFpsTrace(std::string file) { double fps = -1.0; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(file.c_str(), realPath) == nullptr)) { + if ((realpath(file.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return fps; } diff --git a/host/smartperf/client/client_command/parse_slide_fps_trace.cpp b/host/smartperf/client/client_command/parse_slide_fps_trace.cpp index 5c9f95fed..db9388ec6 100644 --- a/host/smartperf/client/client_command/parse_slide_fps_trace.cpp +++ b/host/smartperf/client/client_command/parse_slide_fps_trace.cpp @@ -25,7 +25,7 @@ double ParseSlideFpsTrace::ParseSlideFpsTraceNoh(std::string file) { double fps = -1.0; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(file.c_str(), realPath) == nullptr)) { + if ((realpath(file.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return fps; } diff --git a/host/smartperf/client/client_command/parse_start_frame_trace.cpp b/host/smartperf/client/client_command/parse_start_frame_trace.cpp index da97271a9..d078578dd 100644 --- a/host/smartperf/client/client_command/parse_start_frame_trace.cpp +++ b/host/smartperf/client/client_command/parse_start_frame_trace.cpp @@ -33,7 +33,7 @@ double StartFrameTraceNoh::ParseStartFrameTraceNoh(std::string file) { double frameRate = -1.0; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(file.c_str(), realPath) == nullptr)) { + if ((realpath(file.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return frameRate; } diff --git a/host/smartperf/client/client_command/parse_start_trace_noh.cpp b/host/smartperf/client/client_command/parse_start_trace_noh.cpp index 6efb2c76d..35e070fba 100644 --- a/host/smartperf/client/client_command/parse_start_trace_noh.cpp +++ b/host/smartperf/client/client_command/parse_start_trace_noh.cpp @@ -30,7 +30,7 @@ double ParseStartTraceNoh::ParseStartTraceNohe(std::string file) { double codeTime = -1.0; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(file.c_str(), realPath) == nullptr)) { + if ((realpath(file.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return codeTime; } diff --git a/host/smartperf/client/client_command/parse_trace.cpp b/host/smartperf/client/client_command/parse_trace.cpp index 5503db392..e13493ebb 100644 --- a/host/smartperf/client/client_command/parse_trace.cpp +++ b/host/smartperf/client/client_command/parse_trace.cpp @@ -30,7 +30,7 @@ double ParseTrace::ParseTraceNoh(const std::string &fileNamePath, const std::str int conversion = 1000; double code = -1; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(fileNamePath.c_str(), realPath) == nullptr)) { + if ((realpath(fileNamePath.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return code; } @@ -124,7 +124,7 @@ double ParseTrace::ParseTraceCold(const std::string &fileNamePath, const std::st int conversion = 1000; double code = -1; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(fileNamePath.c_str(), realPath) == nullptr)) { + if ((realpath(fileNamePath.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return code; } @@ -145,7 +145,7 @@ double ParseTrace::ParseTraceHot(const std::string &fileNamePath) int conversion = 1000; double code = -1; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(fileNamePath.c_str(), realPath) == nullptr)) { + if ((realpath(fileNamePath.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return code; } diff --git a/host/smartperf/client/client_command/profiler_fps.cpp b/host/smartperf/client/client_command/profiler_fps.cpp index 54633b07c..fac2a2f48 100644 --- a/host/smartperf/client/client_command/profiler_fps.cpp +++ b/host/smartperf/client/client_command/profiler_fps.cpp @@ -30,7 +30,6 @@ #include "include/ByTrace.h" #include "include/startup_delay.h" - namespace OHOS { namespace SmartPerf { std::map ProfilerFPS::ItemData() @@ -229,7 +228,6 @@ void ProfilerFPS::GetFPS(std::vector v) printf("SP_daemon exec finished!\n"); } - FpsInfoProfiler ProfilerFPS::GetFpsInfo() { processFlag = false; diff --git a/host/smartperf/client/client_command/sp_utils.cpp b/host/smartperf/client/client_command/sp_utils.cpp index aa1df044c..60d51d552 100644 --- a/host/smartperf/client/client_command/sp_utils.cpp +++ b/host/smartperf/client/client_command/sp_utils.cpp @@ -62,7 +62,7 @@ bool SPUtils::Cmp(const std::string &a, const std::string &b) bool SPUtils::LoadFile(const std::string &filePath, std::string &content) { char realPath[PATH_MAX] = {0x00}; - if (!(realpath(filePath.c_str(), realPath) == nullptr)) { + if ((realpath(filePath.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return false; } diff --git a/host/smartperf/client/client_command/stalling_rate_trace.cpp b/host/smartperf/client/client_command/stalling_rate_trace.cpp index f1230a44a..e85130cb4 100644 --- a/host/smartperf/client/client_command/stalling_rate_trace.cpp +++ b/host/smartperf/client/client_command/stalling_rate_trace.cpp @@ -26,7 +26,7 @@ double StallingRateTrace::StallingRateResult(std::string file) { double stalligRate = 0; char realPath[PATH_MAX] = {0x00}; - if (!(realpath(file.c_str(), realPath) == nullptr)) { + if ((realpath(file.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return stalligRate; } diff --git a/host/smartperf/client/client_command/startup_delay.cpp b/host/smartperf/client/client_command/startup_delay.cpp index ec3934544..41133b46f 100644 --- a/host/smartperf/client/client_command/startup_delay.cpp +++ b/host/smartperf/client/client_command/startup_delay.cpp @@ -147,7 +147,7 @@ std::string StartUpDelay::GetPidByPkg(const std::string &curPkgName) void StartUpDelay::InitXY2(const std::string &curAppName, const std::string &fileName, const std::string &appPkgName) { char realPath[PATH_MAX] = {0x00}; - if (!(realpath(fileName.c_str(), realPath) == nullptr)) { + if ((realpath(fileName.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return; } @@ -197,7 +197,7 @@ void StartUpDelay::InitXY2(const std::string &curAppName, const std::string &fil void StartUpDelay::InitXY(const std::string &curAppName, const std::string &fileName) { char realPath[PATH_MAX] = {0x00}; - if (!(realpath(fileName.c_str(), realPath) == nullptr)) { + if ((realpath(fileName.c_str(), realPath) == nullptr)) { std::cout << "Error: Unable to get real path" << std::endl; return; }