Skip to content

Instantly share code, notes, and snippets.

@senghoo
Last active February 26, 2021 08:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senghoo/9432546c18aebb48b4add78be811a6df to your computer and use it in GitHub Desktop.
Save senghoo/9432546c18aebb48b4add78be811a6df to your computer and use it in GitHub Desktop.
func_clock
#include <iostream>
#include <unistd.h>
using namespace std;
#define T(f) do { \
time_t start = clock(); \
f; \
cout << #f << " running time is " <<float(clock()-start)/CLOCKS_PER_SEC<<" s"<<endl; \
}while (0)
void function_a(int a){
long product;
for(int i=0; i<a; i++){
for(int j=0; j<a; j++){
product = i*j;
}
}
}
int main(int argc, char *argv[]) {
T(function_a(1000));
T(function_a(10000));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment