1 #ifdef PETSC_RCS_HEADER 2 static char vcid[] = "$Id: PetscGetCPUTime.c,v 1.4 1999/03/19 21:24:35 bsmith Exp balay $"; 3 #endif 4 5 #include "petsc.h" 6 7 #undef __FUNC__ 8 #define __FUNC__ "main" 9 int main( int argc, char **argv) 10 { 11 PLogDouble x, y; 12 long int i,j,A[100000],ierr; 13 14 PetscInitialize(&argc, &argv,0,0); 15 /* To take care of paging effects */ 16 ierr = PetscGetCPUTime(&y);CHKERRA(ierr); 17 18 for ( i=0; i<2; i++ ) { 19 ierr = PetscGetCPUTime(&x);CHKERRA(ierr); 20 21 /* 22 Do some work for at least 1 ms. Most CPU timers 23 cannot measure anything less than that 24 */ 25 26 for (j=0; j<20000*(i+1); j++) { 27 A[j]=i+j; 28 } 29 ierr = PetscGetCPUTime(&y);CHKERRA(ierr); 30 fprintf(stderr,"%-15s : %e sec\n","PetscGetCPUTime", (y-x)/10.0); 31 } 32 33 PetscFinalize(); 34 PetscFunctionReturn(0); 35 } 36