19 #include "gtest/gtest.h" 25 TEST(RateTimerTest, ComputeRate) {
28 for (
int i = 0; i < 100; ++i) {
29 rate_timer.Pulse(time);
32 EXPECT_NEAR(10., rate_timer.ComputeRate(), 1e-3);
35 struct SimulatedClock {
36 using rep = std::chrono::steady_clock::rep;
37 using period = std::chrono::steady_clock::period;
38 using duration = std::chrono::steady_clock::duration;
39 using time_point = std::chrono::steady_clock::time_point;
43 static time_point now() noexcept {
return time; }
48 TEST(RateTimerTest, ComputeWallTimeRateRatio) {
51 for (
int i = 0; i < 100; ++i) {
52 rate_timer.Pulse(time);
54 SimulatedClock::time +=
55 std::chrono::duration_cast<SimulatedClock::duration>(
56 std::chrono::duration<double>(0.05));
58 EXPECT_NEAR(2., rate_timer.ComputeWallTimeRateRatio(), 1e-3);
UniversalTimeScaleClock::time_point Time
Time FromUniversal(const int64 ticks)
Duration FromSeconds(const double seconds)
static constexpr bool is_steady