r305_dm/TP1/Exo3/ij_ji.c

38 lines
531 B
C
Raw Permalink Normal View History

2023-09-07 15:38:31 +02:00
/* accès mémoire */
#include <stdio.h>
#include <time.h>
2023-09-07 15:38:31 +02:00
#include <stdlib.h>
#define N 8192
2023-09-07 15:38:31 +02:00
int t[N][N];
static inline double tstamp(void)
{
2023-09-07 15:38:31 +02:00
struct timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
return tv.tv_sec + tv.tv_nsec * 1.0e-9;
}
int main()
{
int i, j;
double t1, t2;
t1 = tstamp();
2023-09-07 15:38:31 +02:00
/* version 1 */
2023-09-07 15:38:31 +02:00
// for(i=0;i<N;i++) for(j=0;j<N;j++)
// t[i][j] = 1;
2023-09-07 15:38:31 +02:00
/* version 2 */
2023-09-07 15:38:31 +02:00
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
t[j][i] = 1;
2023-09-07 15:38:31 +02:00
//
t2 = tstamp();
printf("time = %lf\n", t2 - t1);
2023-09-07 15:38:31 +02:00
return 0;
}