In this lesson, you’ll extend your testbed to add some logging so you can trace how long it takes to calculate your result. You’ll measure the execution time with the
time.time() function, which we’ll use to compare the single-threaded and multithreaded implementations of the same algorithm.
Note: The code example here uses the
time.time() function to measure execution time. This is quite a simplistic approach (or potentially even incorrect, since
time.time() isn’t guaranteed to be monotonic). To learn more about how to accurately measure the execution time of your Python code, check out our Python Timer Functions tutorial.
In the next lesson, you’ll take a look at the
multiprocessing.Pool class and its parallel
map implementation, which make it a lot easier to parallelize most Python code that is written in a functional style.