Skip to content

timer.stop()#

Stops the Timer. Should always be called after timer.start().

Parameters:

Name Type Description Default
thread str | None

Option to stop specific thread.

None
Example

Basic usage:

Python
1
2
3
4
5
6
7
8
from timer import Timer

timer = Timer()
timer.start()

# Insert your code here

timer.stop()

Terminal output example:

Elapsed time: 12.34 seconds

With custom thread name and decimals:

Python
1
2
3
4
5
6
7
8
from timer import Timer

timer = Timer()
timer.start(thread="my_thread", decimals=5)

# Insert your code here

timer.stop(thread="my_thread")

Terminal output example:

Elapsed time: 0.12345 seconds for thread MY_THREAD