stopwatch package

Submodules

stopwatch.stopwatch module

Stopwatch class for timing portions of python code

class stopwatch.stopwatch.Tick(time: float, action: str, name: str)[source]

Bases: object

time: float
action: str
name: str
class stopwatch.stopwatch.Stopwatch[source]

Bases: object

Stopwatch Instance

A typical lifecycle of the stopwatch:

[creation] –> [start] –> [tick, pause, resume] –> [stop]

start()[source]

Start the stopwatch

tick(name=None)[source]

Record a tick

Return type

Time since the last tick

pause()[source]

Pause the stopwatch (Ticks are not recorded until resumed)

resume()[source]

Resume

Return type

Time for which the instance was paused

stop()[source]

Stops the stopwatch

Return type

Total time (including pause-time)

get_time_paused(start_idx=0, end_idx=- 1)[source]

Get pause-time

property time_paused

Get pause-time

property time_active
property time_total
time_elapsed(start_idx=0, end_idx=- 1, start_name=None, end_name=None, exclude_pause=True)[source]

Get time elapsed between different ticks

Parameters

exclude_pause (boolean) – If True, pause-time is not counted. The default is True.

Return type

Total runtime (with or without pause-time)

last()[source]

Return the time between the last two ticks

current()[source]

Return the time elapsed since the last tick

stopwatch.stopwatch.main()[source]

Module contents

Stopwatch class for timing your python code with support for pause, resume and multiple named-ticks.