#include <doctest/doctest.h>
#include "WallClockTimer.hpp"
#include <chrono>
#include <thread>
Go to the source code of this file.
◆ TEST_SUITE()
TEST_SUITE |
( |
"Instruments" |
| ) |
|
Definition at line 14 of file InstrumentTests.cpp.
References WallClockTimer::GetMeasurements(), WallClockTimer::GetName(), WallClockTimer::Start(), WallClockTimer::Stop(), and WallClockTimer::WALL_CLOCK_TIME.
16 TEST_CASE(
"WallClockTimerInMicroseconds")
20 CHECK((std::string(wallClockTimer.
GetName()) == std::string(
"WallClockTimer")));
23 wallClockTimer.
Start();
26 std::this_thread::sleep_for(std::chrono::microseconds(10));
29 wallClockTimer.
Stop();
31 CHECK((wallClockTimer.
GetMeasurements().front().m_Name == WallClockTimer::WALL_CLOCK_TIME));
34 CHECK_GE(wallClockTimer.
GetMeasurements().front().m_Value, std::chrono::microseconds(10).count());
37 TEST_CASE(
"WallClockTimerInNanoseconds")
41 CHECK((std::string(wallClockTimer.
GetName()) == std::string(
"WallClockTimer")));
44 wallClockTimer.
Start();
47 std::this_thread::sleep_for(std::chrono::nanoseconds(500));
50 wallClockTimer.
Stop();
52 CHECK((wallClockTimer.
GetMeasurements().front().m_Name == WallClockTimer::WALL_CLOCK_TIME));
56 std::chrono::duration_cast<std::chrono::duration<double, std::micro>>(std::chrono::nanoseconds(500));
59 CHECK_GE(wallClockTimer.
GetMeasurements().front().m_Value, delta.count());
const char * GetName() const override
std::vector< Measurement > GetMeasurements() const override