fix of rsJankStats

Signed-off-by: jason <zhoujianghao@huawei.com>
Change-Id: I056d7836dcff14a9fc7e8182d6c1dbd7260d64f3
This commit is contained in:
jason 2023-06-15 09:56:24 +08:00
parent 17714e460a
commit 18cef57809
3 changed files with 20 additions and 18 deletions

View File

@ -70,7 +70,7 @@ EPS_LCD_FREQ:
JANK_STATS_RS:
__BASE: {type: STATISTIC, level: MINOR, tag: performance, desc: jank statistic}
STARTTIME: {type: UINT32, desc: begin time since last report}
DURATION: {type: UINT32, desc: duration since last report}
JANK_STATS: {type: STRING, desc: jank frame stats}
STARTTIME: {type: UINT64, desc: begin time since last report}
DURATION: {type: UINT64, desc: duration since last report}
JANK_STATS: {type: UINT16, desc: jank frame stats}
JANK_STATS_VER: {type: UINT32, desc: jank range version}

View File

@ -36,7 +36,7 @@ RSJankStats& RSJankStats::GetInstance()
void RSJankStats::SetStartTime()
{
auto start = std::chrono::steady_clock::now().time_since_epoch();
auto start = std::chrono::system_clock::now().time_since_epoch();
startTime_ = std::chrono::duration_cast<std::chrono::milliseconds>(start).count();
if (isfirstSetStart_) {
lastReportTime_ = startTime_;
@ -46,7 +46,7 @@ void RSJankStats::SetStartTime()
void RSJankStats::SetEndTime()
{
auto end = std::chrono::steady_clock::now().time_since_epoch();
auto end = std::chrono::system_clock::now().time_since_epoch();
endTime_ = std::chrono::duration_cast<std::chrono::milliseconds>(end).count();
auto duration = endTime_ - startTime_;
if (duration >= VSYNC_PERIOD) {
@ -77,27 +77,27 @@ void RSJankStats::SetRSJankStats(int times)
ROSEN_LOGW("RSInterfaces::SetJankStatas Jank Frame Skip more than 180");
return;
}
if (rsJankStats_[type] != ULONG_MAX) {
if (rsJankStats_[type] != USHRT_MAX) {
rsJankStats_[type]++;
}
isNeedReport_ = true;
}
void RSJankStats::ReportJankStats()
{
auto report = std::chrono::steady_clock::now().time_since_epoch();
if (!isNeedReport_) {
ROSEN_LOGW("RSInterfaces::ReportJankStats Nothing need to report");
return;
}
auto report = std::chrono::system_clock::now().time_since_epoch();
auto reportTime = std::chrono::duration_cast<std::chrono::milliseconds>(report).count();
auto reportDuration = reportTime - lastReportTime_;
std::string msg = "";
for (int index = 0; index < JANK_STATS_SIZE; index++) {
msg += std::to_string(rsJankStats_[index]);
rsJankStats_[index] = 0;
msg += ",";
}
auto reportName = "JANK_STATS_RS";
HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::GRAPHIC, reportName,
OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, "STARTTIME", lastReportTime_, "DURATION", reportDuration,
"JANK_STATS", msg, "JANK_STATS_VER", 1);
"JANK_STATS", rsJankStats_, "JANK_STATS_VER", 1);
lastReportTime_ = reportTime;
isNeedReport_ = false;
}
} // namespace Rosen

View File

@ -17,6 +17,7 @@
#define ROSEN_JANK_STATS_H
#include <cstdint>
#include <vector>
namespace OHOS {
namespace Rosen {
@ -37,10 +38,11 @@ private:
void operator=(const RSJankStats&&) = delete;
constexpr static int JANK_STATS_SIZE = 8;
bool isfirstSetStart_ = true;
uint32_t startTime_ = 0;
uint32_t endTime_ = 0;
uint32_t lastReportTime_ = 0;
uint64_t rsJankStats_[JANK_STATS_SIZE] = { 0 };
bool isNeedReport_ = false;
uint64_t startTime_ = 0;
uint64_t endTime_ = 0;
uint64_t lastReportTime_ = 0;
std::vector<uint16_t> rsJankStats_ = std::vector<uint16_t>(JANK_STATS_SIZE, 0);
enum JankRangeType : int16_t {
JANK_FRAME_6_FREQ = 0,