xref: /petsc/src/benchmarks/PetscTime.c (revision abdd934af67c1cc360c4d0cfcf2de16e188d627e)
1 #include <petscsys.h>
2 #include <petsctime.h>
3 
main(int argc,char ** argv)4 int main(int argc, char **argv)
5 {
6   PetscLogDouble x, y;
7   int            i;
8 
9   PetscCall(PetscInitialize(&argc, &argv, 0, 0));
10   /* To take care of paging effects */
11   PetscTime(&y);
12 
13   for (i = 0; i < 2; i++) {
14     PetscTime(&x);
15     PetscTime(&y);
16     PetscTime(&y);
17     PetscTime(&y);
18     PetscTime(&y);
19     PetscTime(&y);
20     PetscTime(&y);
21     PetscTime(&y);
22     PetscTime(&y);
23     PetscTime(&y);
24     PetscTime(&y);
25     fprintf(stdout, "%-15s : %e sec\n", "PetscTime", (y - x) / 10.0);
26   }
27   PetscTime(&x);
28   PetscCall(PetscSleep(10));
29   PetscTime(&y);
30   fprintf(stdout, "%-15s : %e sec - Slept for 10 sec \n", "PetscTime", (y - x));
31   PetscCall(PetscFinalize());
32   return 0;
33 }
34