!1295 响应时延和完成时延合并命令行

Merge pull request !1295 from project-two/master
This commit is contained in:
openharmony_ci 2024-01-03 08:16:25 +00:00 committed by Gitee
commit 4738f6cf0e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 98 additions and 39 deletions

View File

@ -31,7 +31,7 @@ int ClientControl::SocketStart(std::string args)
read(clientSocket, buffer, numBuff);
send(clientSocket, message1, strlen(message1), 0);
read(clientSocket, buffer, numBuff);
if (strcmp(buffer, "start::true") == 0) {
if (strcmp(buffer, "start::True") == 0) {
std::cout << "SP_daemon Collection begins" << std::endl;
} else {
std::cout << "SP_daemon Collection begins failed" << std::endl;
@ -44,7 +44,7 @@ int ClientControl::SocketStop()
OHOS::SmartPerf::ClientControl::InitSocket();
send(clientSocket, message2, strlen(message2), 0);
read(clientSocket, buffer, numBuff);
if (strcmp(buffer, "stop::true") == 0) {
if (strcmp(buffer, "stop::True") == 0) {
std::cout << "SP_daemon Collection ended" << std::endl;
std::cout << "Output Path: data/local/tmp/smartperf/1/t_index_info.csv" << std::endl;
} else {

View File

@ -18,6 +18,7 @@
#include <cstring>
#include <map>
#include <sstream>
#include <future>
#include "include/control_call_cmd.h"
#include "include/startup_delay.h"
#include "include/parse_trace.h"
@ -54,8 +55,6 @@ std::string ControlCallCmd::GetResult(std::vector<std::string> v)
result = SmartPerf::ControlCallCmd::SlideFps(v);
} else if (v[typeName] == "pagefps") {
result = SmartPerf::ControlCallCmd::PageFps();
} else if (v[typeName] == "FPS") {
result = SmartPerf::ControlCallCmd::SlideFPS(v);
} else if (v[typeName] == "startFrame") {
result = SmartPerf::ControlCallCmd::StartFrameFps(v);
} else if (v[typeName] == "fpsohtest") {
@ -68,6 +67,8 @@ std::string ControlCallCmd::GetResult(std::vector<std::string> v)
result = ControlCallCmd::GetAppStartTime();
} else if (v[typeName] == "slideList") {
result = ControlCallCmd::SlideList();
} else if (v[typeName] == "timmeDelay") {
result = ControlCallCmd::TimeDelay();
}
if (time == noNameType) {
std::cout << "Startup error, unknown application or application not responding" << std::endl;
@ -80,6 +81,33 @@ std::string ControlCallCmd::GetResult(std::vector<std::string> v)
}
return result;
}
std::string ControlCallCmd::TimeDelay()
{
OHOS::SmartPerf::ParseClickResponseTrace pcrt;
OHOS::SmartPerf::StartUpDelay sd;
std::string cmdResult;
OHOS::SmartPerf::Radar radar;
SPUtils::LoadCmd("rm -rfv /data/local/tmp/sp_trace_delay.ftrace", cmdResult);
std::string traceName = std::string("/data/local/tmp/") + std::string("sp_trace_") + "delay" + ".ftrace";
std::thread thGetTrace = sd.ThreadGetTrace("delay", traceName);
std::thread thGetHisysId = sd.ThreadGetHisysIdResponse();
std::thread thGetHisysId2 = sd.ThreadGetHisysIdComplete();
std::future<std::string> futureResult = std::async(std::launch::async, SPUtils::GetRadarResponse);
std::future<std::string> futureResult2 = std::async(std::launch::async, SPUtils::GetRadarComplete);
std::string str = futureResult.get();
std::string str2 = futureResult2.get();
thGetTrace.join();
thGetHisysId.join();
thGetHisysId2.join();
double strResponseTime = radar.ParseRadarResponse(str);
stream << strResponseTime;
double strCompleteTime = radar.ParseRadarResponse(str2);
std::ostringstream streamComplete;
streamComplete << strCompleteTime;
std::string resultTime = "ResponseTime:" + stream.str() + "ms\n" +
"CompleteTime:" + streamComplete.str() + "ms";
return resultTime;
}
std::string ControlCallCmd::SlideList()
{
OHOS::SmartPerf::ParseClickResponseTrace pcrt;
@ -152,35 +180,6 @@ std::string ControlCallCmd::SlideFps(std::vector<std::string> v)
std::string fps = parseFPS.ParseTraceFile(traceName, v[typePKG]);
return fps;
}
std::string ControlCallCmd::SlideFPS(std::vector<std::string> v)
{
OHOS::SmartPerf::StartUpDelay sd;
ParseFPS parseFPS;
std::string cmdResult;
int type = 4;
int typePKG = 3;
SPUtils::LoadCmd("rm -rfv /data/local/tmp/*.json", cmdResult);
SPUtils::LoadCmd("rm -rfv /data/local/tmp/*.ftrace", cmdResult);
SPUtils::LoadCmd("uitest dumpLayout", cmdResult);
sleep(1);
size_t position = cmdResult.find(":");
size_t position2 = cmdResult.find("json");
std::string pathJson = cmdResult.substr(position + 1, position2 - position + typePKG);
std::string deviceType = sd.GetDeviceType();
sd.InitXY2(v[type], pathJson, v[typePKG]);
std::string traceName = std::string("/data/local/tmp/") + std::string("sp_trace_") + "fps" + ".ftrace";
std::string cmd = "uinput -T -d " + sd.pointXY + " -u " + sd.pointXY;
sleep(1);
SPUtils::LoadCmd(cmd, cmdResult);
sleep(1);
std::thread thGetTrace = sd.ThreadGetTrace("fps", traceName);
sleep(1);
cmd = "uinput -T -m 650 1500 650 500 30";
SPUtils::LoadCmd(cmd, cmdResult);
thGetTrace.join();
std::string fps = parseFPS.ParseTraceFile(traceName, v[typePKG]);
return fps;
}
double ControlCallCmd::ResponseTime()
{
OHOS::SmartPerf::ParseClickResponseTrace pcrt;

View File

@ -28,7 +28,6 @@ public:
double CompleteTime();
double ResponseTime();
double StartResponse(std::vector<std::string> v);
static std::string SlideFPS(std::vector<std::string> v);
static std::string SlideFps(std::vector<std::string> v);
double PageFps();
std::string StartFrameFps(std::vector<std::string> v);
@ -36,6 +35,7 @@ public:
std::string GetFrame();
std::string GetAppStartTime();
std::string SlideList();
std::string TimeDelay();
private:
bool isOhTest = false;
std::string result = "";

View File

@ -25,6 +25,10 @@ public:
std::thread ThreadGetLayout();
void InputEvent(const std::string &point);
std::thread ThreadInputEvent(const std::string &point);
void GetHisysIdResponse();
std::thread ThreadGetHisysIdResponse();
void GetHisysIdComplete();
std::thread ThreadGetHisysIdComplete();
void GetHisysId();
std::thread ThreadGetHisysId();
void ChangeToBackground();

View File

@ -76,19 +76,65 @@ void StartUpDelay::GetHisysId()
std::stringstream ss(str);
std::string line = "";
getline(ss, line);
std::stringstream ss_line(line);
std::stringstream ssLine(line);
std::string word = "";
std::string second_str;
std::string secondStr;
int count = 0;
int num = 2;
while (ss_line >> word) {
while (ssLine >> word) {
count++;
if (count == num) {
second_str = word;
secondStr = word;
break;
}
}
SPUtils::LoadCmd("kill " + second_str, str);
SPUtils::LoadCmd("kill " + secondStr, str);
}
void StartUpDelay::GetHisysIdResponse()
{
int time = 10;
sleep(time);
std::string str = "";
SPUtils::LoadCmd("ps -ef |grep INTERACTION_RESPONSE_LATENCY", str);
std::stringstream ss(str);
std::string line = "";
getline(ss, line);
std::stringstream ssLine(line);
std::string word = "";
std::string secondStr;
int count = 0;
int num = 2;
while (ssLine >> word) {
count++;
if (count == num) {
secondStr = word;
break;
}
}
SPUtils::LoadCmd("kill " + secondStr, str);
}
void StartUpDelay::GetHisysIdComplete()
{
int time = 10;
sleep(time);
std::string str = "";
SPUtils::LoadCmd("ps -ef |grep INTERACTION_COMPLETED_LATENCY", str);
std::stringstream ss(str);
std::string line = "";
getline(ss, line);
std::stringstream ssLine(line);
std::string word = "";
std::string secondStr;
int count = 0;
int num = 2;
while (ssLine >> word) {
count++;
if (count == num) {
secondStr = word;
break;
}
}
SPUtils::LoadCmd("kill " + secondStr, str);
}
bool StartUpDelay::GetSpTcp()
{
@ -103,11 +149,21 @@ bool StartUpDelay::GetSpTcp()
}
return flagTcp;
}
std::thread StartUpDelay::ThreadGetHisysIdResponse()
{
std::thread thGetHisysIdResponse(&StartUpDelay::GetHisysIdResponse, this);
return thGetHisysIdResponse;
}
std::thread StartUpDelay::ThreadGetHisysId()
{
std::thread thGetHisysId(&StartUpDelay::GetHisysId, this);
return thGetHisysId;
}
std::thread StartUpDelay::ThreadGetHisysIdComplete()
{
std::thread thGetHisysIdComplete(&StartUpDelay::GetHisysIdComplete, this);
return thGetHisysIdComplete;
}
void StartUpDelay::ChangeToBackground()
{
std::string result;