Skip to content

Instantly share code, notes, and snippets.

@blabos-zz
Created September 22, 2010 01:31
Show Gist options
  • Save blabos-zz/590957 to your computer and use it in GitHub Desktop.
Save blabos-zz/590957 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <time.h>
#define MAX 512
int array[MAX][MAX][MAX];
int main(void) {
int i, j, k;
clock_t t1, t2;
t1 = clock();
for (i = 0; i < MAX; i++) {
for (j = 0; j < MAX; j++) {
for (k = 0; k < MAX; k++) {
array[k][j][i] = i * j * k;
}
}
}
t2 = clock();
printf("M: %f secs\n", (t2 - t1 + 0.0)/CLOCKS_PER_SEC);
t1 = clock();
for (i = 0; i < MAX; i++) {
for (j = 0; j < MAX; j++) {
for (k = 0; k < MAX; k++) {
array[i][j][k] = i * j * k;
}
}
}
t2 = clock();
printf("C: %f secs\n", (t2 - t1 + 0.0)/CLOCKS_PER_SEC);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment