| 619 | #endif // OS_ANDROID |
| 620 | |
| 621 | TEST(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 | |
| 648 | static void HighResClockTest(TimeTicks (*GetTicks)()) { |
| 649 | #if defined(OS_WIN) |
nothing calls this directly
no test coverage detected