Skip to content

Instantly share code, notes, and snippets.

@Ben-0-mad
Created August 20, 2021 23:20
Show Gist options
  • Save Ben-0-mad/b27c6d9e5d398a9916110282ca5b7171 to your computer and use it in GitHub Desktop.
Save Ben-0-mad/b27c6d9e5d398a9916110282ca5b7171 to your computer and use it in GitHub Desktop.
C++ timing of fuctions
#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