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