Introducere în testarea în Python
Alexander Levin
Data Scientist
Performanță - cât de eficient utilizează software-ul resursele sistemului pentru a îndeplini o sarcină.
Testarea performanței - un tip de testare care măsoară performanța software-ului.
Resurse:
Cazuri:
Instalare:
pip install pytest-benchmark
# Example_1.py
import time
def test_func(benchmark):
benchmark(time.sleep, 1)
Comandă CLI:
pytest Example_1.py
Rezultatele după executarea comenzii CLI:

Pentru time.sleep(3) în loc de time.sleep(1):

# Example_2.py
import time
def test_func(benchmark):
@benchmark
def sleep_for_1_sec():
time.sleep(1)
Comandă CLI:
pytest Example_2.py
pytest-benchmark prin:benchmark@benchmark ca decoratorIntroducere în testarea în Python