Skip to content
/ timer Public

A simple timer module to get the number of seconds between two timestamps.

License

Notifications You must be signed in to change notification settings

zoziha/timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Timer

Language license

A simple timer module to get the number of seconds between two timestamps.

Only FPM is supported, other build systems can copy the source file (./src/*.f90) directly.

Usage

To use timer within your fpm project, add the following lines to your fpm.toml file:

[dependencies]
timer = { git="https://github.com/zoziha/timer" }

Example

> fpm run --example --all  # run the example
program example_day_timer

    use timer_module, only: day_timer_type, sec2hms
    implicit none

    type(day_timer_type) :: tmr

    call tmr%tic()
    call sleep(1)
    print *, 'Elapsed day time: ', tmr%toc(), ' sec'
    print *, 'Elapsed day time: ', sec2hms(tmr%toc()), ' (h:m:s)'
    print *, 'Elapsed day time: ', tmr%toc_string(), ' (d/h:m)'

end program example_day_timer
! Elapsed day time:    1.01499999      sec
! Elapsed day time: 00:00:01 (h:m:s)
! Elapsed day time: 00/00:00 (d/h:m)