Created
August 20, 2021 23:20
-
-
Save Ben-0-mad/b27c6d9e5d398a9916110282ca5b7171 to your computer and use it in GitHub Desktop.
C++ timing of fuctions
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
#include <iostream> | |
#include <chrono> | |
long add(int a, int b) { | |
return a + b; | |
} | |
int main() { | |
auto start = std::chrono::steady_clock::now(); | |
std::cout << "9 + 10 = " << add(9, 10) << '\n'; | |
auto end = std::chrono::steady_clock::now(); | |
std::chrono::duration<double> elapsed_seconds = end - start; | |
std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n"; | |
std::cin.get(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment