Python’s time module gives you four different ways to measure time: monotonic(), perf_counter(), process_time(), and time(). And they don’t all agree with each other. One ignores your system clock. One ignores sleep() entirely. One can run backwards.
In six minutes, Mahdi Shadkam-Farrokhi walks through all four with live demos, including winding the system clock back an hour mid-measurement to show which functions notice and which don’t. By the end, you’ll know which function belongs in a timeout, which belongs in a benchmark, which belongs in a profiler, and which belongs in a log line.
Then take it further: the full video course abstracts these functions into a reusable Timer class, extends it to handle multiple timers, turns it into a data class, and finally makes it work as a context manager.
Resources mentioned in this lesson:
Course
Python Timer Functions
Learn how to time your Python code with the time module, then build a reusable Timer class that works as a context manager.