1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
"""
Just to make sure the plugin doesn't choke on doctests::
>>> print('Yay, doctests!')
Yay, doctests!
"""
import sys # noqa
import time
from functools import partial
import pytest
@pytest.mark.skipif('sys.platform == "win32"')
def test_fast(benchmark):
@benchmark
def result():
return time.sleep(0.000001)
assert result is None
if not benchmark.disabled:
assert benchmark.stats.stats.min >= 0.000001
def test_slow(benchmark):
assert benchmark(partial(time.sleep, 0.001)) is None
def test_slower(benchmark):
benchmark(lambda: time.sleep(0.01))
@pytest.mark.benchmark(min_rounds=2, timer=time.time, max_time=0.01)
def test_xfast(benchmark):
benchmark(str)
@pytest.fixture(params=range(5))
def foo(request):
return request.param
@pytest.mark.skipif('sys.platform == "win32"')
def test_parametrized(benchmark, foo):
benchmark(time.sleep, 0.00001)
if benchmark.enabled:
assert benchmark.stats.stats.min >= 0.00001
|