Actual source code: petsctime.h

  1: /*
  2:        Low cost access to system time. This, in general, should not
  3:      be included in user programs.
  4: */

  6: #if !defined(PETSCTIME_H)
  7: #define PETSCTIME_H
  8: #include <petscsys.h>

 10: PETSC_EXTERN PetscErrorCode PetscGetCPUTime(PetscLogDouble*);

 12: /* Global counters */
 13: PETSC_EXTERN PetscLogDouble petsc_BaseTime;

 15: /*MC
 16:    PetscTime - Returns the current time of day in seconds.

 18:    Synopsis:
 19: #include <petsctime.h>
 20:     PetscErrorCode PetscTime(PetscLogDouble *v)

 22:    Not Collective

 24:    Output Parameter:
 25: .  v - time counter

 27:    Usage:
 28:      PetscLogDouble v;
 29:      PetscTime(&v);
 30:      .... perform some calculation ...
 31:      printf("Time for operation %g\n",v);

 33:    Level: developer

 35:    Notes:
 36:    Since the PETSc libraries incorporate timing of phases and operations,
 37:    we do not recommend ever using PetscTime()
 38:    The options database command  -log_view activate
 39:    PETSc library timing. See Users-Manual: ch_profiling for more details.

 41: .seealso:  PetscTimeSubtract(), PetscTimeAdd(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd()

 43: M*/

 45: /*MC
 46:    PetscTimeSubtract - Subtracts the current time of day (in seconds) from
 47:    the value v.

 49:    Synopsis:
 50: #include <petsctime.h>
 51:     PetscErrorCode PetscTimeSubtract(PetscLogDouble *v)

 53:    Not Collective

 55:    Input Parameter:
 56: .  v - time counter

 58:    Output Parameter:
 59: .  v - time counter (v = v - current time)

 61:    Level: developer

 63:    Notes:
 64:    Since the PETSc libraries incorporate timing of phases and operations,
 65:    we do not every recommend using PetscTimeSubtract()
 66:    The options database command  -log_view activates
 67:    PETSc library timing.  See Users-Manual: ch_profiling for more details, also
 68:    see PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd() for how to register
 69:    stages and events in application codes.

 71: .seealso:  PetscTime(), PetscTimeAdd(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd()

 73: M*/

 75: /*MC
 76:    PetscTimeAdd - Adds the current time of day (in seconds) to the value v.

 78:    Synopsis:
 79: #include <petsctime.h>
 80:     PetscErrorCode PetscTimeAdd(PetscLogDouble *v)

 82:    Not Collective

 84:    Input Parameter:
 85: .  v - time counter

 87:    Output Parameter:
 88: .  v - time counter (v = v + current time)

 90:    Level: developer

 92:    Notes:
 93:    Since the PETSc libraries incorporate timing of phases and operations,
 94:    we do not ever recommend using PetscTimeAdd().
 95:    The options database command -log_view activate
 96:    PETSc library timing. See Users-Manual: ch_profiling for more details.

 98: .seealso:  PetscTime(), PetscTimeSubtract(), PetscLogStageRegister(), PetscLogEventRegister(), PetscLogEventBegin(), PetscLogEventEnd()

100: M*/

102: PETSC_STATIC_INLINE PetscErrorCode PetscTime(PetscLogDouble *v)
103: {
104:   *v = MPI_Wtime();
105:   return 0;
106: }

108: PETSC_STATIC_INLINE PetscErrorCode PetscTimeSubtract(PetscLogDouble *v)
109: {
110:   *v -= MPI_Wtime();
111:   return 0;
112: }

114: PETSC_STATIC_INLINE PetscErrorCode PetscTimeAdd(PetscLogDouble *v)
115: {
116:   *v += MPI_Wtime();
117:   return 0;
118: }

120: #endif