Created
April 14, 2016 08:05
-
-
Save PaulChana/7edd2e1238188c57ce924161cb05d3aa to your computer and use it in GitHub Desktop.
Timing function C++11
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 <cmath> | |
#include <iomanip> | |
#include <chrono> | |
int fun(const int a, const int b, const int c) { | |
return a * b * c; | |
} | |
int main(int argc, const char * argv[]) { | |
for (int i = 0; i < 101; i++) { | |
float x = static_cast<float>(i) / 100.f; | |
auto start = std::chrono::steady_clock::now(); | |
auto t1 = fun(i, i * 5, i * 10); | |
auto end = std::chrono::steady_clock::now(); | |
std::cout << "T1 -> " << std::chrono::duration <double, std::nano> (end - start).count(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment