Created
August 31, 2025 22:22
-
-
Save Iksas/72dc2b576c63ce48d19ee3ed464f9422 to your computer and use it in GitHub Desktop.
C++ benchmark template
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
| #include <iostream> | |
| #include <chrono> | |
| using namespace std; | |
| int main() | |
| { | |
| chrono::steady_clock::time_point begin = chrono::steady_clock::now(); | |
| // The code to benchmark goes here... | |
| chrono::steady_clock::time_point end = chrono::steady_clock::now(); | |
| cout << "Time difference = " << chrono::duration_cast<std::chrono::seconds>(end - begin).count() << "[s]" << std::endl; | |
| cout << "Time difference = " << chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() << "[ms]" << std::endl; | |
| cout << "Time difference = " << chrono::duration_cast<std::chrono::microseconds>(end - begin).count() << "[us]" << std::endl; | |
| cout << "Time difference = " << chrono::duration_cast<std::chrono::nanoseconds> (end - begin).count() << "[ns]" << std::endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment