Actual source code: PetscGetCPUTime.c

     2:  #include petsc.h

      6: int main(int argc,char **argv)
      7: {
      8:   PetscLogDouble x,y;
      9:   long int   i,j,A[100000],ierr;
     10:
     11:   PetscInitialize(&argc,&argv,0,0);
     12:  /* To take care of paging effects */
     13:   PetscGetCPUTime(&y);

     15:   for (i=0; i<2; i++) {
     16:     PetscGetCPUTime(&x);

     18:     /*
     19:        Do some work for at least 1 ms. Most CPU timers
     20:        cannot measure anything less than that
     21:      */
     22:
     23:     for (j=0; j<20000*(i+1); j++) {
     24:       A[j]=i+j;
     25:     }
     26:     PetscGetCPUTime(&y);
     27:     fprintf(stdout,"%-15s : %e sec\n","PetscGetCPUTime",(y-x)/10.0);
     28:   }

     30:   PetscFinalize();
     31:   return(0);
     32: }