Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
memleak founds by cppcheck
[simgrid.git] / examples / gras / chrono / chrono.c
index eb31f9a..c703981 100644 (file)
@@ -20,18 +20,22 @@ int multiplier (int argc,char *argv[])
 {
   int i,j,k,l;
   double *A,*B,*C;
-  int n = 500;
+  int n = 100;
   double start = 0.0;
+  double now = 0.0;
 
-  gras_init(&argc, argv, NULL);
+  gras_init(&argc, argv);
 
   A = malloc(n*n*sizeof(double));
   B = malloc(n*n*sizeof(double));
   C = malloc(n*n*sizeof(double));
 
-  INFO1("Before computation: %lg", start=gras_os_time());
+  start=now=gras_os_time();
+
+  INFO1("Begin matrix multiplication loop (time: %g)", start);
 
   for(l=0; l<4; l++) {
+    now=gras_os_time();
     GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
     for(i=0; i<n; i++)
       for(j=0; j<n; j++) {
@@ -46,10 +50,36 @@ int multiplier (int argc,char *argv[])
          C[i*n+j] += A[i*n+k]*B[k*n+j];
     
     GRAS_BENCH_ONCE_RUN_ONCE_END();
+    now=gras_os_time()-now;
+    INFO2("Iteration %d : %g ", l, now);
   }
 
-  start = gras_os_time()-start;
-  INFO2("After computation: %lg; Duration: %lg ", gras_os_time(), start);
+  now=gras_os_time()-start;
+  INFO2("End matrix multiplication loop (time: %g; Duration: %g)", gras_os_time(), now);
 
+  start=now=gras_os_time();
+  INFO1("Begin malloc loop (time: %g)", start);
+  for(l=0; l<4; l++) {
+    now=gras_os_time();
+    GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
+     free(A);
+     A = malloc(n*n*sizeof(double));
+    GRAS_BENCH_ONCE_RUN_ONCE_END();
+    now=gras_os_time()-now;
+    INFO2("Iteration %d : %g ", l, now);
+  }
+   
+  start=now=gras_os_time();
+  INFO1("Begin integer incrementation loop (time: %g)", start);
+  for(l=0; l<4; l++) {
+    GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
+    j++;
+    GRAS_BENCH_ONCE_RUN_ONCE_END();
+  }
+  free(A);
+  free(B);
+  free(C);
+   
+  gras_exit();
   return 0;
 }