version 0.6.0
Loading...
Searching...
No Matches

Timer to measure elapsed time More...

Data Types

type  mod_timer::t_timer
 Timer class. More...
 

Detailed Description

The t_timer class defines a cumulative timer. See example below.

Example:

class(t_timer) :: timer
! The timer was never started. `timer%is_triggered()` will return .false.
if (timer%is_triggered()) write(*,'()')
! Start timer
call timer%start()
! ... TASK 1 ...
! Stop timer
call timer%stop()
! Display elapsed time of 'TASK 1'
if (timer%is_triggered()) write(*,'(,g0,)') timer%get_elapsed_time()
! Start timer again
call timer%start()
! Starting timer twice has no effect
call timer%start()
! ... TASK 2 ...
! Stop timer
call timer%stop()
! Display elapsed time of 'TASK 1' + 'TASK 2'
write(*,'(,g0,)') timer%get_elapsed_time()
! Reset timer
call timer%reset()
! Will print 0.0 s
write(*,'(,g0,)') timer%get_elapsed_time()
! The timer was reset. `timer%is_triggered()` will return .false.
if (timer%is_triggered()) write(*,'()')