Module stopwatch
Allows to easily time blocks of code.
The result will be logged.
Functions
start (watch_name) | Start a watch with the given name. |
stop (watch_name, message, decimal_places) | Stops the watch with the given name, logging the duration. |
stop_only (watch_name) | Stops the watch with the given name and returns the duration for which the watch has been running. |
Functions
- start (watch_name)
-
Start a watch with the given name.
Parameters:
- watch_name The name of the watch to start.
- stop (watch_name, message, decimal_places)
-
Stops the watch with the given name, logging the duration.
It will be logged as info in the format "watch_name: duration ms" or if the message is provided "message: duration ms"
Parameters:
- watch_name The name of the watch to stop.
- message Optional. The message to use for the log instead of the name.
- decimal_places Optional. To how many decimal places the time should be rounded. Defaults to 3.
- stop_only (watch_name)
-
Stops the watch with the given name and returns the duration for which
the watch has been running.
Parameters:
- watch_name The name of the watch to stop.
Returns:
-
The duration of the watch. -1 if it never was started.