Stopwatch Derived Type

type, public :: Stopwatch

Class for timing sections of code, See the Stopwatch_Class module documentation for usage.



Type-Bound Procedures

procedure, public :: start => start_Stopwatch

Start the Stopwatch

  • private subroutine start_Stopwatch(this, title, iunit)

    Start the Stopwatch

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    character(len=*), optional :: title

    Name to label the start of the stopwatch

    integer(kind=i32), optional :: iunit

    File ID to write to

procedure, public :: stop => stop_Stopwatch

Stop the Stopwatch

  • private subroutine stop_Stopwatch(this, title, iunit)

    Stop the Stopwatch

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    character(len=*), optional :: title

    Name to label the stopped stopwatch

    integer(kind=i32), optional :: iunit

    File ID to write to

procedure, public :: reset => reset_Stopwatch

Reset the Stopwatch

  • private subroutine reset_Stopwatch(this)

    Reset the Stopwatch

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

procedure, public :: restart => restart_Stopwatch

Restart the Stopwatch

  • private subroutine restart_Stopwatch(this)

    Restart the Stopwatch

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

procedure, public :: time => time_Stopwatch

Get the current or stopped time

  • private function time_Stopwatch(this) result(res)

    Get the time

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    Return Value character(len=:), allocatable

    Time in format HH:MM:SS.MSEC

procedure, public :: lap => lap_Stopwatch

Lap the Stopwatch

  • private function lap_Stopwatch(this) result(res)

    Get the lap time

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    Return Value character(len=:), allocatable

    Lap time in format HH:MM:SS.MSEC

procedure, public :: lapInSeconds => lapInSeconds_Stopwatch

Get the lap time in seconds

  • private function lapInSeconds_Stopwatch(this) result(res)

    Get the lap time in seconds

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    Return Value real(kind=r64)

    Laptime in seconds

procedure, public :: elapsed => elapsed_Stopwatch

Get the current elapsed time

  • private function elapsed_Stopwatch(this) result(res)

    Get the elapsed time

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    Return Value character(len=:), allocatable

    Elapsed time in format HH:MM:SS.MSEC

procedure, public :: elapsedInSeconds => elapsedInSeconds_Stopwatch

Get the elapsed time in seconds

  • private function elapsedInSeconds_Stopwatch(this) result(res)

    Get the elapsed time in seconds

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    Return Value real(kind=r64)

    Elapsed time in seconds

procedure, public :: date => date_Stopwatch

Print the date

  • private function date_Stopwatch(this) result(res)

    Get the date

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    Return Value character(len=:), allocatable

    Date in format DD/MM/YYYY

procedure, public :: dateAndTime => dateAndTime_Stopwatch

Print the date and time

  • private function dateAndTime_Stopwatch(this) result(res)

    Get the date and time

    Arguments

    Type IntentOptional AttributesName
    class(Stopwatch) :: this

    Stopwatch Class

    Return Value character(len=:), allocatable

    Date and time in format DD/MM/YYYY HH:MM:SS.MSEC