Date: 2022-08-02T03:15:18+00:00

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;
      9:   PetscBool      flg;

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

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

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

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

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

     55:   PetscFinalize();
     56:   return 0;
     57: }