MCPcopy Create free account
hub / github.com/apache/brpc / TEST

Function TEST

test/time_unittest.cc:621–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619#endif // OS_ANDROID
620
621TEST(TimeTicks, Deltas) {
622 for (int index = 0; index < 50; index++) {
623 TimeTicks ticks_start = TimeTicks::Now();
624 butil::PlatformThread::Sleep(butil::TimeDelta::FromMilliseconds(10));
625 TimeTicks ticks_stop = TimeTicks::Now();
626 TimeDelta delta = ticks_stop - ticks_start;
627 // Note: Although we asked for a 10ms sleep, if the
628 // time clock has a finer granularity than the Sleep()
629 // clock, it is quite possible to wakeup early. Here
630 // is how that works:
631 // Time(ms timer) Time(us timer)
632 // 5 5010
633 // 6 6010
634 // 7 7010
635 // 8 8010
636 // 9 9000
637 // Elapsed 4ms 3990us
638 //
639 // Unfortunately, our InMilliseconds() function truncates
640 // rather than rounds. We should consider fixing this
641 // so that our averages come out better.
642 EXPECT_GE(delta.InMilliseconds(), 9);
643 EXPECT_GE(delta.InMicroseconds(), 9000);
644 EXPECT_EQ(delta.InSeconds(), 0);
645 }
646}
647
648static void HighResClockTest(TimeTicks (*GetTicks)()) {
649#if defined(OS_WIN)

Callers

nothing calls this directly

Calls 13

HighResClockTestFunction · 0.85
IsThreadNowSupportedFunction · 0.85
FromUTCExplodedFunction · 0.85
InMillisecondsMethod · 0.80
InMicrosecondsMethod · 0.80
InSecondsMethod · 0.80
InDaysMethod · 0.80
InHoursMethod · 0.80
InMinutesMethod · 0.80
InSecondsFMethod · 0.80
InMillisecondsFMethod · 0.80
ToTimeSpecMethod · 0.80

Tested by

no test coverage detected