Created
March 8, 2016 19:34
-
-
Save Staticity/bca79c8de20e82ebeeba to your computer and use it in GitHub Desktop.
Timer Macro
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 <opencv.hpp> | |
#include <stdio.h> | |
#define PROFILE(function_name, ...) \ | |
{ \ | |
long long start = cv::getTickCount(); \ | |
function_name(__VA_ARGS__); \ | |
long long end = cv::getTickCount(); \ | |
double time_spent = (end - start) / cv::getTickFrequency(); \ | |
printf("%s(%d): %f seconds\n", \ | |
#function_name, \ | |
__VA_ARGS__, \ | |
time_spent); \ | |
} | |
int run(int x) | |
{ | |
if (x == 0) | |
return 1; | |
return run(x - 1) + run(x - 1); | |
} | |
int main() | |
{ | |
for (int i = 0; i < 25; ++i) | |
PROFILE(run, i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment