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