PetscTime — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# PetscTime

Returns the current time from some base time in the past in seconds.

## Synopsis

    static inline PetscErrorCode PetscTime(PetscLogDouble *v)

Not Collective

## Output Parameter

- v - time counter

## Usage

         PetscLogDouble v;
         PetscTime(&v);
         .... perform some calculation ...
         printf("Time for operation %g\n",v);

## Note

Since the PETSc libraries incorporate timing of phases and operations, we do not recommend ever using `PetscTime()`. The options database command `-log_view` activates PETSc library timing. See `PetscLogStageRegister()`, `PetscLogEventRegister()`, `PetscLogEventBegin()`, `PetscLogEventEnd()` for how to register stages and events in application codes.

## See Also

`PetscTimeSubtract()`, `PetscTimeAdd()`, `PetscLogStageRegister()`, `PetscLogEventRegister()`, `PetscLogEventBegin()`, `PetscLogEventEnd()`

## Level

developer

## Location

include/petsctime.h

## Examples

src/sys/tutorials/ex6.c
src/sys/tutorials/ex7.c
src/ksp/ksp/tutorials/bench_kspsolve.c

Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages