Date: 2013-07-02T14:52:30+00:00

Actual source code: PLogEvent.c
petsc-3.4.2 2013-07-02

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

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

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

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

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

     47:   PetscOptionsHasName(NULL,"-log",&flg);
     48:   if (flg) fprintf(stderr,"-log ");
     49:   PetscOptionsHasName(NULL,"-log_all",&flg);
     50:   if (flg) fprintf(stderr,"-log_all ");
     51:   PetscOptionsHasName(NULL,"-log_summary",&flg);
     52:   if (flg) fprintf(stderr,"-log_summary ");
     53:   PetscOptionsHasName(NULL,"-log_mpe",&flg);
     54:   if (flg) fprintf(stderr,"-log_mpe ");

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

     58:   PetscFinalize();
     59:   return(0);
     60: }