Skip to content
Snippets Groups Projects
Commit 17c94219 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Allow to start timer from a given time point

parent b2591c6f
Branches
No related tags found
1 merge request!199Integrate checkpointing
...@@ -107,6 +107,10 @@ class Timer ...@@ -107,6 +107,10 @@ class Timer
m_status{Status::running} m_status{Status::running}
{} {}
Timer(const std::chrono::time_point<std::chrono::high_resolution_clock>& start)
: m_start{start}, m_elapsed_sum{std::chrono::duration<double>::zero()}, m_status{Status::running}
{}
~Timer() = default; ~Timer() = default;
}; };
......
...@@ -59,6 +59,11 @@ TEST_CASE("Timer", "[utils]") ...@@ -59,6 +59,11 @@ TEST_CASE("Timer", "[utils]")
t2.reset(); t2.reset();
REQUIRE(t2.status() == Timer::Status::paused); REQUIRE(t2.status() == Timer::Status::paused);
REQUIRE(t2.seconds() == 0); REQUIRE(t2.seconds() == 0);
using namespace std::chrono_literals;
Timer t3{std::chrono::high_resolution_clock::now() - 24h};
REQUIRE(t3.status() == Timer::Status::running);
REQUIRE(t3.seconds() > 24 * 3600);
} }
SECTION("stop/start") SECTION("stop/start")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment