Skip to content

Instantly share code, notes, and snippets.

@criso
Last active December 10, 2015 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save criso/4374094 to your computer and use it in GitHub Desktop.
Save criso/4374094 to your computer and use it in GitHub Desktop.
Calculate function execution time
#include <time.h>
#include "lib/dbg.h"
void my_function() {
}
int main (int argc, char const* argv[]) {
clock_t begin, end;
double time_spent;
begin = clock();
my_function();
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
log_info("function exec time: %f", time_spent);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment