未验证 提交 64569938 编写于 作者: O openharmony_ci 提交者: Gitee

!2130 Fix: 修改时间单位与换算不统一

Merge pull request !2130 from cheng_jinsong/init_0719
......@@ -146,10 +146,10 @@ static int BootEventTraversal(ListNode *node, void *root)
{
static int start = 0;
BOOT_EVENT_PARAM_ITEM *item = (BOOT_EVENT_PARAM_ITEM *)node;
double forkTime = item->timestamp[BOOTEVENT_FORK].tv_sec * SECTOMSEC +
(double)item->timestamp[BOOTEVENT_FORK].tv_nsec / MSECTONSEC;
double readyTime = item->timestamp[BOOTEVENT_READY].tv_sec * SECTOMSEC +
(double)item->timestamp[BOOTEVENT_READY].tv_nsec / MSECTONSEC;
double forkTime = item->timestamp[BOOTEVENT_FORK].tv_sec * MSECTONSEC +
(double)item->timestamp[BOOTEVENT_FORK].tv_nsec / USTONSEC;
double readyTime = item->timestamp[BOOTEVENT_READY].tv_sec * MSECTONSEC +
(double)item->timestamp[BOOTEVENT_READY].tv_nsec / USTONSEC;
double durTime = readyTime - forkTime;
if (item->pid == 0) {
if (durTime < SAVEINITBOOTEVENTMSEC) {
......
......@@ -33,9 +33,9 @@ extern "C" {
#define BOOT_EVENT_TIMESTAMP_MAX_LEN 50
#define BOOT_EVENT_FILEPATH_MAX_LEN 60
#define BOOT_EVENT_FINISH 2
#define SECTOMSEC 1000000
#define MSECTONSEC 1000000
#define SECTONSEC 1000000000
#define MSECTONSEC 1000
#define USTONSEC 1000
#define SAVEINITBOOTEVENTMSEC 100000
#define BOOTEVENT_OUTPUT_PATH "/data/service/el0/startup/init/"
......
......@@ -61,9 +61,9 @@ static int TraversalEvent(ListNode *node, void *root)
len = sprintf_s(args->buffer + args->currLen, args->bufferLen - args->currLen, ",%u:%u,%u:%u;",
(uint32_t)item->timestamp[BOOTEVENT_FORK].tv_sec,
(uint32_t)(item->timestamp[BOOTEVENT_FORK].tv_nsec / MSECTONSEC),
(uint32_t)(item->timestamp[BOOTEVENT_FORK].tv_nsec / USTONSEC),
(uint32_t)item->timestamp[BOOTEVENT_READY].tv_sec,
(uint32_t)(item->timestamp[BOOTEVENT_READY].tv_nsec / MSECTONSEC));
(uint32_t)(item->timestamp[BOOTEVENT_READY].tv_nsec / USTONSEC));
PLUGIN_CHECK(len > 0 && (((uint32_t)len + args->currLen) < args->bufferLen), return -1,
"Failed to format service time %s", item->paramName);
args->currLen += (uint32_t)len;
......@@ -88,8 +88,8 @@ PLUGIN_STATIC void ReportBootEventComplete(ListNode *events)
StartupTimeEvent startupTime = {};
startupTime.event.type = STARTUP_TIME;
startupTime.totalTime = curr.tv_sec;
startupTime.totalTime = startupTime.totalTime * SECTOMSEC;
startupTime.totalTime += curr.tv_nsec / MSECTONSEC;
startupTime.totalTime = startupTime.totalTime * MSECTONSEC;
startupTime.totalTime += curr.tv_nsec / USTONSEC;
startupTime.detailTime = buffer;
char *reason = buffer + MAX_BUFFER_FOR_EVENT;
uint32_t size = PARAM_VALUE_LEN_MAX;
......@@ -102,7 +102,7 @@ PLUGIN_STATIC void ReportBootEventComplete(ListNode *events)
startupTime.firstStart = 0;
}
PLUGIN_LOGI("SysEventInit %u.%u detailTime len %u '%s'",
(uint32_t)curr.tv_sec, (uint32_t)(curr.tv_nsec / MSECTONSEC), args.currLen, startupTime.detailTime);
(uint32_t)curr.tv_sec, (uint32_t)(curr.tv_nsec / USTONSEC), args.currLen, startupTime.detailTime);
ReportSysEvent(&startupTime.event);
free(buffer);
}
......
......@@ -102,8 +102,8 @@ HWTEST_F(SysEventUnitTest, SysEventTest_004, TestSize.Level1)
StartupTimeEvent startupTime = {};
startupTime.event.type = STARTUP_TIME;
startupTime.totalTime = curr.tv_sec;
startupTime.totalTime = startupTime.totalTime * SECTOMSEC;
startupTime.totalTime += curr.tv_nsec / MSECTONSEC;
startupTime.totalTime = startupTime.totalTime * MSECTONSEC;
startupTime.totalTime += curr.tv_nsec / USTONSEC;
startupTime.detailTime = const_cast<char *>("buffer");
startupTime.reason = const_cast<char *>("");
startupTime.firstStart = 1;
......@@ -119,8 +119,8 @@ HWTEST_F(SysEventUnitTest, SysEventTest_005, TestSize.Level1)
StartupTimeEvent startupTime = {};
startupTime.event.type = STARTUP_EVENT_MAX;
startupTime.totalTime = curr.tv_sec;
startupTime.totalTime = startupTime.totalTime * SECTOMSEC;
startupTime.totalTime += curr.tv_nsec / MSECTONSEC;
startupTime.totalTime = startupTime.totalTime * MSECTONSEC;
startupTime.totalTime += curr.tv_nsec / USTONSEC;
startupTime.detailTime = const_cast<char *>("buffer");
startupTime.reason = const_cast<char *>("");
startupTime.firstStart = 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册