# MPI Time measurement **Time measurement** uses `MPI_Wtime()` for wall-clock time. Reduce with `MPI_MAX` across all processes to get the true elapsed time (set by the slowest). ```c MPI_Barrier(MPI_COMM_WORLD); // align all processes before starting the clock double t0 = MPI_Wtime(); do_work(); double elapsed = MPI_Wtime() - t0; double max_elapsed; MPI_Reduce(&elapsed, &max_elapsed, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD); if (rank == 0) printf("%.6f s (timer resolution: %.2e s)\n", max_elapsed, MPI_Wtick()); ``` Reducing with `MPI_MAX` gives the true wall time of the parallel section, which is set by the slowest process. A mean would undercount if processes finish at different times. For microbenchmarks, wrap the timed region in a loop and divide by the iteration count to stay well above the timer resolution.