Module to provide timing facilities.
The simplest way is using the module variable.
Using wall time
call tic()
call slow_operation()
call toc("slow operation is done")
or CPU time
call cputic()
call slow_operation()
call cputoc("slow operation is done")
Alternatively, if thread safety is required, you can keep track of the start time yourself.
integer :: start_time
call tic(start_time)
call slow_operation()
call toc("slow operation is done", start_time)
or
real :: start_time
call cputic(start_time)
call slow_operation()
call cputoc("slow operation is done", start_time)
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private, | save | :: | wall_clock_tic | = | -1000 |
Wall clock time at last call of |
| real(kind=dp), | private, | save | :: | cpu_clock_tic | = | -1000.0_dp |
CPU time at last call of |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | private | :: | start_time | ||||
| integer, | private | :: | program_start_time | ||||
| real(kind=dp), | public | :: | init_time | ||||
| real(kind=dp), | public | :: | matrix_time | ||||
| real(kind=dp), | public | :: | evp_time | ||||
| real(kind=dp), | public | :: | eigenfunction_time | ||||
| real(kind=dp), | public | :: | datfile_time |
| procedure, public :: start_timer | |
| procedure, public :: end_timer | |
| procedure, public :: get_total_time |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(timer_t), | intent(inout) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(timer_t), | intent(in) | :: | this |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(timer_t), | intent(inout) | :: | this |
Subroutine to start a wall clock timer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(out), | optional | :: | start_time |
Optional output for the start time. If not present the time is written to a module variable. |
Subroutine to end a wall clock timer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | message |
Message to log along elapsed time. |
||
| integer, | intent(in), | optional | :: | start_time |
Optional starting time. If not present the time recorded in the module variable is used. |
|
| character(len=*), | intent(in), | optional | :: | level |
The level (severity) of the message, default is "debug". |
Subroutine to start a CPU timer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real, | intent(out), | optional | :: | start_time |
Optional output for the start time. If not present the time is written to a module variable. |
Subroutine to end a CPU timer.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | message |
Message to log along elapsed time. |
||
| real(kind=dp), | intent(in), | optional | :: | start_time |
Optional starting time. If not present the time recorded in the module variable is used. |
|
| character(len=*), | intent(in), | optional | :: | level |
The level (severity) of the message, default is "debug". |