!1650 采集数据写入csv

Merge pull request !1650 from 金海/master
This commit is contained in:
openharmony_ci 2024-06-05 06:10:59 +00:00 committed by Gitee
commit 3c32d5a326
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
17 changed files with 39 additions and 29 deletions

View File

@ -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<long long> jitters, int cfps) const
{
@ -74,13 +72,7 @@ TraceStatus ByTrace::CheckFpsJitters(std::vector<long long> 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;
}
}
}

View File

@ -41,7 +41,13 @@ std::map<std::string, std::string> 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";

View File

@ -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;
}

View File

@ -32,6 +32,7 @@ public:
TraceStatus CheckFpsJitters(std::vector<long long> 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;
};
}
}

View File

@ -102,6 +102,7 @@ private:
int fifty = 50;
FpsCurrentFpsTime ffTime;
bool processFlag = false;
std::string screen = "0";
};
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -30,7 +30,6 @@
#include "include/ByTrace.h"
#include "include/startup_delay.h"
namespace OHOS {
namespace SmartPerf {
std::map<std::string, std::string> ProfilerFPS::ItemData()
@ -229,7 +228,6 @@ void ProfilerFPS::GetFPS(std::vector<std::string> v)
printf("SP_daemon exec finished!\n");
}
FpsInfoProfiler ProfilerFPS::GetFpsInfo()
{
processFlag = false;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}