Last active
February 26, 2021 08:09
-
-
Save senghoo/9432546c18aebb48b4add78be811a6df to your computer and use it in GitHub Desktop.
func_clock
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 <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