#include < stdio.h >
#include < stdlib.h >
#include < time.h >
#include < math.h >
int main();
int main() {
long int i,a;
clock_t cputime,cputime1;
double timing,timing0;
cputime= clock();
for(i=0;i<10000000;i++){
a=pow(4,2);
a=pow(4,2);
a=pow(4,2);
a=pow(4,2);
a=pow(4,2);
}
cputime1= clock();
timing0=((double) cputime1-cputime);
timing=((double) cputime1-cputime) / CLOCKS_PER_SEC;
printf("timing =%12.9f clock per sec=%d timing0=%12.9f\n",
timing,CLOCKS_PER_SEC,timing0);
exit(0);
}
The art of data science and scientific computing
by Mehmet Süzen
See also: Science Memo
Request one-on-one session
Wednesday, 20 February 2008
CPU Timing in a C code
Examine this simple example :
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment