-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add timer capabilities to cli, refactor args
Co-authored-by: Maksim Shagov <43129418+MaksimShagov@users.noreply.github.com>
- Loading branch information
1 parent
c140a1f
commit 37ac49a
Showing
4 changed files
with
181 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <chrono> | ||
|
||
namespace utils { | ||
|
||
struct Timer { | ||
using TimePoint = std::chrono::time_point<std::chrono::steady_clock>; | ||
|
||
Timer() = default; | ||
Timer(const Timer &) = default; | ||
Timer(Timer &&) = default; | ||
~Timer() = default; | ||
|
||
void start() { | ||
startPoint = std::chrono::steady_clock::now(); | ||
} | ||
|
||
void stop() { | ||
stopPoint = std::chrono::steady_clock::now(); | ||
} | ||
|
||
// Obtain elapsed time in milliseconds | ||
auto elapsed() const { | ||
return std::chrono::duration_cast<std::chrono::milliseconds>(stopPoint - startPoint).count(); | ||
} | ||
|
||
private: | ||
TimePoint startPoint; | ||
TimePoint stopPoint; | ||
}; | ||
|
||
} // namespace utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.