1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Testing in Python

Connected

Exercise

Finding an element

Using the right data structure can significantly increase the performance of your code. For example, if you want to find a certain element in the data, you might want to choose between list and set. In this exercise, you will implement performance tests with pytest to compare the speed of the in operator applied correspondingly to the two data structures: list and set. The pytest package has already been imported.

Instructions

100 XP
  • Pass benchmark as an argument into the test functions.
  • Then call benchmark() in the test functions passing find() as the first argument.