Created
June 13, 2020 03:02
-
-
Save quiye/e12661134f2301c82bbe18114d08ff87 to your computer and use it in GitHub Desktop.
simple stop watch (timer)
This file contains hidden or 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
class stopWatch { | |
private: | |
decltype(std::chrono::high_resolution_clock::now()) start = std::chrono::high_resolution_clock::now(); | |
public: | |
~stopWatch() { | |
const auto finish = std::chrono::high_resolution_clock::now(); | |
const auto durationMilliSeconds = std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count(); | |
std::cout << durationMilliSeconds << " ms" << std::endl; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage