API

class chronometer.Chronometer(timer=monotonic)[source]

Simple timer meant to be used for measuring how much time has been spent in a certain code region.

start()[source]

Starts the timer.

Returns:Returns the timer itself.
Return type:Chronometer
Raises TimerAlreadyStartedError:
 If the timer is already running.
stop()[source]

Stops the timer.

Returns:Time passed since the timer has been started in seconds.
Return type:float
Raises TimerAlreadyStoppedError:
 If the timer is already stopped.
reset()[source]

Resets the timer.

Returns:Elapsed time before the timer was reset.
Return type:float
elapsed[source]

Returns time passed in seconds.

Returns:Time passed since the timer has been started in seconds.
Return type:float
stopped[source]

Returns if the timer is stopped or not.

Returns:True if the timer is stopped and False otherwise.
Return type:bool
started[source]

Returns if the timer is running or not.

Returns:True if the timer is running and False otherwise.
Return type:bool
class chronometer.RelaxedStartChronometer(timer=monotonic)[source]

Relaxed version which won’t raise an exception on double starting the timer.

start()[source]

Starts the timer or just returns if the timer is already running.

Returns:Returns the timer itself.
Return type:RelaxedStartChronometer
class chronometer.RelaxedStopChronometer(timer=monotonic)[source]

Relaxed version which won’t raise an exception on double stopping the timer.

stop()[source]

Stops the timer or just returns if the timer is already stopped.

Returns:Time passed since the timer has been started in seconds.
Return type:float
class chronometer.RelaxedChronometer(timer=monotonic)[source]

Ultra relaxed version which won’t throw any exceptions on its own.

exception chronometer.ChronoRuntimeError[source]

Base exceptions for errors which happened inside Chronometer.

exception chronometer.ChronoAlreadyStoppedError[source]

Raised when trying to stop a stopped timer.

exception chronometer.ChronoAlreadyStartedError[source]

raised when trying to start a started timer.

Related Topics

This Page