From 29e0b5c0f008ceb5f800b8633964376d1d71d474 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 15 May 2017 11:26:41 -0400 Subject: [PATCH] Support for division for timers --- include/CLI/Timer.hpp | 2 +- tests/TimerTest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index edb7eaa..9c8b8f0 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -74,7 +74,7 @@ public: std::string make_time_str() const { time_point stop = clock::now(); std::chrono::duration elapsed = stop - start_; - double time = elapsed.count(); + double time = elapsed.count() / cycles; return make_time_str(time); } diff --git a/tests/TimerTest.cpp b/tests/TimerTest.cpp index 529ce09..c9a357b 100644 --- a/tests/TimerTest.cpp +++ b/tests/TimerTest.cpp @@ -12,7 +12,7 @@ TEST(Timer, MSTimes) { CLI::Timer timer{"My Timer"}; std::this_thread::sleep_for(std::chrono::milliseconds(123)); std::string output = timer.to_string(); - std::new_output = (timer / 1000000).to_string(); + std::string new_output = (timer / 1000000).to_string(); EXPECT_THAT(output, HasSubstr("My Timer")); EXPECT_THAT(output, HasSubstr(" ms")); EXPECT_THAT(new_output, HasSubstr(" ns")); -- libgit2 0.21.4