From 79a3fa27b80b6421cf306efb5d12afe4fe292a67 Mon Sep 17 00:00:00 2001 From: nanxiansen Date: Mon, 17 May 2021 11:52:22 +0800 Subject: [PATCH] =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E5=86=85=E6=A0=B8?= =?UTF-8?q?=E5=AD=90=E7=B3=BB=E7=BB=9Ftime=5Fposix=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=B8=8D=E7=A8=B3=E5=AE=9A=E7=94=A8=E4=BE=8B:SleepTest.cpp#tes?= =?UTF-8?q?tUsleepAccuracy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic48db9b6b4aff165c91d1214a6b8b83747a6b841 --- kernel_lite/time_posix/src/SleepTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel_lite/time_posix/src/SleepTest.cpp b/kernel_lite/time_posix/src/SleepTest.cpp index f3f50235c..f74f0f7eb 100755 --- a/kernel_lite/time_posix/src/SleepTest.cpp +++ b/kernel_lite/time_posix/src/SleepTest.cpp @@ -48,7 +48,7 @@ HWTEST_P(UsleepParamTest, testUsleepAccuracy, Performance | SmallTest | Level1) int rt = usleep(interval); clock_gettime(CLOCK_MONOTONIC, &time2); EXPECT_EQ(rt, 0); - duration = (time2.tv_sec - time1.tv_sec)*1000000 + (time2.tv_nsec - time1.tv_nsec)/1000; + duration = (time2.tv_sec*1000000 + time2.tv_nsec/1000) - (time1.tv_sec*1000000 + time1.tv_nsec/1000); LOG("testloop %d, actual usleep duration: %ld us", i, duration); d += duration; } @@ -58,7 +58,7 @@ HWTEST_P(UsleepParamTest, testUsleepAccuracy, Performance | SmallTest | Level1) ASSERT_NEAR(d, interval, SLEEP_ACCURACY) << "usleep accuracy check fail\n"; } INSTANTIATE_TEST_CASE_P(SleepTest, UsleepParamTest, - testing::Values(100, 1000, 10*1000, 20*1000, 30*1000, 300*1000, 3000*1000)); + testing::Values(1000, 10*1000, 20*1000, 30*1000, 300*1000, 3000*1000)); /** * @tc.number SUB_KERNEL_TIME_API_SLEEP_0100 @@ -107,7 +107,7 @@ HWTEST_F(SleepTest, testNanosleepAccuracy, Performance | SmallTest | Level2) int rt = nanosleep(&req, &rem); clock_gettime(CLOCK_MONOTONIC, &time2); EXPECT_EQ(rt, 0); - duration = (time2.tv_sec - time1.tv_sec)*1000000 + (time2.tv_nsec - time1.tv_nsec)/1000; + duration = (time2.tv_sec*1000000 + time2.tv_nsec/1000) - (time1.tv_sec*1000000 + time1.tv_nsec/1000); LOG("testloop %d, actual sleep duration: %.1f s", i, duration); d += duration; } @@ -134,7 +134,7 @@ HWTEST_F(SleepTest, testClockNanosleepAccuracy, Performance | SmallTest | Level2 int rt = clock_nanosleep(CLOCK_REALTIME, 0, &req, &rem); clock_gettime(CLOCK_MONOTONIC, &time2); EXPECT_EQ(rt, 0); - duration = (time2.tv_sec - time1.tv_sec)*1000000 + (time2.tv_nsec - time1.tv_nsec)/1000; + duration = (time2.tv_sec*1000000 + time2.tv_nsec/1000) - (time1.tv_sec*1000000 + time1.tv_nsec/1000); LOG("testloop %d, actual sleep duration: %.1f s", i, duration); d += duration; } -- GitLab