mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-23 15:00:17 +00:00
响应时延和完成时延合并命令行
Signed-off-by: y1135885 <yuqigang1@huawei.com>
This commit is contained in:
parent
9f1292c067
commit
049311cbd1
@ -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 {
|
||||
|
@ -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"
|
||||
@ -68,6 +69,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 +83,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;
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
std::string GetFrame();
|
||||
std::string GetAppStartTime();
|
||||
std::string SlideList();
|
||||
std::string TimeDelay();
|
||||
private:
|
||||
bool isOhTest = false;
|
||||
std::string result = "";
|
||||
|
@ -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();
|
||||
|
@ -90,6 +90,52 @@ void StartUpDelay::GetHisysId()
|
||||
}
|
||||
SPUtils::LoadCmd("kill " + second_str, 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 ss_line(line);
|
||||
std::string word = "";
|
||||
std::string second_str;
|
||||
int count = 0;
|
||||
int num = 2;
|
||||
while (ss_line >> word) {
|
||||
count++;
|
||||
if (count == num) {
|
||||
second_str = word;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SPUtils::LoadCmd("kill " + second_str, 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 ss_line(line);
|
||||
std::string word = "";
|
||||
std::string second_str;
|
||||
int count = 0;
|
||||
int num = 2;
|
||||
while (ss_line >> word) {
|
||||
count++;
|
||||
if (count == num) {
|
||||
second_str = word;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SPUtils::LoadCmd("kill " + second_str, str);
|
||||
}
|
||||
bool StartUpDelay::GetSpTcp()
|
||||
{
|
||||
std::string str = "";
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user