Skip to content

Instantly share code, notes, and snippets.

@yagays
Last active December 17, 2015 01:49
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 yagays/5531054 to your computer and use it in GitHub Desktop.
Save yagays/5531054 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <time.h>
double A[1024][1024];
int
main(){
int i,j,k;
k = 0;
clock_t start,end;
start = clock();
while (k < 1000){
for (i=0; i<1000; i++){
for (j=0; j<1000; j++){
A[i][j] +=1;
}
}
k++;
}
end = clock();
printf("%.2f sec.\n",(double)(end-start)/CLOCKS_PER_SEC);
}
#include <stdio.h>
#include <time.h>
double A[1024][1024];
int
main(){
int i,j,k;
k = 0;
clock_t start,end;
start = clock();
while (k < 1000){
for (i=0; i<1000; i++){
for (j=0; j<1000; j++){
A[j][i] +=1;
}
}
k++;
}
end = clock();
printf("%.2f sec.\n",(double)(end-start)/CLOCKS_PER_SEC);
}
$ gcc -o c1 c1.c
$ gcc -o c1 c1.c
$ ./c1
4.11 sec.
$ ./c2
26.96 sec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment