Created
December 11, 2024 17:02
-
-
Save tmathews/a83f8864b8d97943472fa0cb66aa7493 to your computer and use it in GitHub Desktop.
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
| struct StopWatch { | |
| std::string label; | |
| std::chrono::steady_clock::time_point start; | |
| std::chrono::steady_clock::time_point finish; | |
| StopWatch() | |
| { | |
| start = std::chrono::steady_clock::now(); | |
| } | |
| StopWatch(const char *str) | |
| { | |
| label = str; | |
| start = std::chrono::steady_clock::now(); | |
| } | |
| void Start() | |
| { | |
| start = std::chrono::steady_clock::now(); | |
| }; | |
| std::chrono::duration<double, std::milli> Stop() | |
| { | |
| finish = std::chrono::steady_clock::now(); | |
| std::chrono::duration<double, std::milli> ms_double = finish - start; | |
| return ms_double; | |
| }; | |
| void PrintEllapsed(const char *sublabel) | |
| { | |
| auto now = std::chrono::steady_clock::now(); | |
| std::chrono::duration<double, std::milli> ms_double = now - start; | |
| std::cout << label << sublabel << ms_double.count() << '\n'; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment