Actual source code: PetscGetCPUTime.c

  1: /*$Id: PetscGetCPUTime.c,v 1.12 2001/08/29 20:59:41 balay Exp $*/

 3:  #include petsc.h

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

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

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

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