Skip to content

Instantly share code, notes, and snippets.

@Staticity
Created March 8, 2016 19:34
Show Gist options
  • Save Staticity/bca79c8de20e82ebeeba to your computer and use it in GitHub Desktop.
Save Staticity/bca79c8de20e82ebeeba to your computer and use it in GitHub Desktop.
Timer Macro
#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