Merge branch 'master' of dwarves.iut-fbleau.fr:moguljak/TP1

This commit is contained in:
Tom MOGULJAK 2023-09-11 22:06:00 +02:00
commit 658b105c44

View File

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