Actual source code: PLogEvent.c

      2: #include <petscsys.h>
      3: #include <petsctime.h>

      5: int main(int argc,char **argv)
      6: {
      7:   PetscLogDouble x,y;
      8:   PetscLogEvent  e1;
     10:   PetscBool      flg;

     12:   PetscInitialize(&argc,&argv,0,0);if (ierr) return ierr;
     13:   PetscLogEventRegister("*DummyEvent",0,&e1);
     14:   /* To take care of the paging effects */
     15:   PetscTime(&x);
     16:   PetscLogEventBegin(e1,&x,0,0,0);
     17:   PetscLogEventEnd(e1,&x,0,0,0);

     19:   PetscTime(&x);
     20:   /* 10 Occurences of the dummy event */
     21:   PetscLogEventBegin(e1,&x,0,0,0);
     22:   PetscLogEventEnd(e1,&x,0,0,0);
     23:   PetscLogEventBegin(e1,&x,&y,0,0);
     24:   PetscLogEventEnd(e1,&x,&y,0,0);
     25:   PetscLogEventBegin(e1,&y,0,0,0);
     26:   PetscLogEventEnd(e1,&y,0,0,0);
     27:   PetscLogEventBegin(e1,&x,0,0,0);
     28:   PetscLogEventEnd(e1,&x,0,0,0);
     29:   PetscLogEventBegin(e1,&x,&y,0,0);
     30:   PetscLogEventEnd(e1,&x,&y,0,0);
     31:   PetscLogEventBegin(e1,&y,0,0,0);
     32:   PetscLogEventEnd(e1,&y,0,0,0);
     33:   PetscLogEventBegin(e1,&x,0,0,0);
     34:   PetscLogEventEnd(e1,&x,0,0,0);
     35:   PetscLogEventBegin(e1,&x,&y,0,0);
     36:   PetscLogEventEnd(e1,&x,&y,0,0);
     37:   PetscLogEventBegin(e1,&y,0,0,0);
     38:   PetscLogEventEnd(e1,&y,0,0,0);
     39:   PetscLogEventBegin(e1,&x,&e1,0,0);
     40:   PetscLogEventEnd(e1,&x,&e1,0,0);

     42:   PetscTime(&y);
     43:   fprintf(stderr,"%-15s : %e sec, with options : ","PetscLogEvent",(y-x)/10.0);

     45:   PetscOptionsHasName(NULL,"-log",&flg);
     46:   if (flg) fprintf(stderr,"-log ");
     47:   PetscOptionsHasName(NULL,"-log_all",&flg);
     48:   if (flg) fprintf(stderr,"-log_all ");
     49:   PetscOptionsHasName(NULL,"-log_view",&flg);
     50:   if (flg) fprintf(stderr,"-log_view ");
     51:   PetscOptionsHasName(NULL,"-log_mpe",&flg);
     52:   if (flg) fprintf(stderr,"-log_mpe ");

     54:   fprintf(stderr,"\n");

     56:   PetscFinalize();
     57:   return ierr;
     58: }