We much recommend using PETSc’s logging for this purpose. If you run with
-log_summary it outputs information about the amount of time and percentage of
time and floating point operations and messages sent etc for different parts of
the code. It also handles summing over all processes.
To add your own events use PetscLogEventRegister(), then at the beginning of
the piece you want timed use PetscLogEventBegin() and PetscLogEventEnd() at the
end.
Barry
MPI_Wtime() can be used
https://www.google.com/search?client=safari&rls=en&q=MPI_Wtime&ie=UTF-8&oe=UTF-8
On Mar 9, 2014, at 12:16 PM, Qiyue Lu <[email protected]> wrote:
> Dear all:
>
> I have a segment of code in PETSc and am trying to measure its execution
> time. Is there built-in functions in PETSc returning the current system time?
> So I can call this function before and after the segment of code then do a
> 'minus' to get the time consumed?
>
> like:
>
> A=get_system_time();
>
> *************************
> the segment of code
> *************************
> B=get_system_time();
>
> Then B-A is the time I am looking for.
>
> Thanks
>
> Qiyue Lu