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