Introduction to Testing in Python
Alexander Levin
Data Scientist
Performance - how efficiently does software utilizes the resources of the system to accomplish a task.
Performance Testing - is a type of testing that measures software performance.
Resources:
Cases:
Installation:
pip install pytest-benchmark
# Example_1.py
import time
def test_func(benchmark):
benchmark(time.sleep, 1)
CLI Command:
pytest Example_1.py
The results we get after we execute the CLI Command:
For time.sleep(3)
instead of time.sleep(1)
:
# Example_2.py
import time
def test_func(benchmark):
@benchmark
def sleep_for_1_sec():
time.sleep(1)
CLI Command:
pytest Example_2.py
pytest-benchmark
fixture by:benchmark
directly@benchmark
as a decoratorIntroduction to Testing in Python