4.2 - Using timeit
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
What is the primary purpose of the timeit module?
💡 Hint: Think about performance measuring in Python.
How would you use the timeit module to measure the time a simple addition takes?
💡 Hint: Remember the syntax involves passing a code string.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What is a primary advantage of the timeit module?
💡 Hint: Think about minimizing variability when testing time.
Using the timeit module with a decorator keeps your code:
💡 Hint: Consider what decorators do in Python.
1 more question available
Challenge Problems
Push your limits with advanced challenges
Devise a way to use the timeit module to benchmark the performance of a plain list versus a numpy array over the same operation of summing elements.
💡 Hint: Consider how to set up both environments in your testing.
Create a function that will aggregate and return execution times of different functions being measured with timeit.
💡 Hint: Think about using a loop to iterate function calls and aggregate the results.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.