Commit 29e0b5c0f008ceb5f800b8633964376d1d71d474

Authored by Henry Fredrick Schreiner
1 parent 416e6a04

Support for division for timers

include/CLI/Timer.hpp
... ... @@ -74,7 +74,7 @@ public:
74 74 std::string make_time_str() const {
75 75 time_point stop = clock::now();
76 76 std::chrono::duration<double> elapsed = stop - start_;
77   - double time = elapsed.count();
  77 + double time = elapsed.count() / cycles;
78 78 return make_time_str(time);
79 79 }
80 80  
... ...
tests/TimerTest.cpp
... ... @@ -12,7 +12,7 @@ TEST(Timer, MSTimes) {
12 12 CLI::Timer timer{"My Timer"};
13 13 std::this_thread::sleep_for(std::chrono::milliseconds(123));
14 14 std::string output = timer.to_string();
15   - std::new_output = (timer / 1000000).to_string();
  15 + std::string new_output = (timer / 1000000).to_string();
16 16 EXPECT_THAT(output, HasSubstr("My Timer"));
17 17 EXPECT_THAT(output, HasSubstr(" ms"));
18 18 EXPECT_THAT(new_output, HasSubstr(" ns"));
... ...