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