Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baseline benchmarking tests #54

Merged
merged 5 commits into from
Jul 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
sudo: false
language: python
python:

- '2.6'
- '2.7'
- '3.3'
- '3.4'
- '3.5'
- '3.6-dev'
- '3.6'
- pypy
- nightly

# command to install dependencies
install: "pip install -U tox"
# # command to run tests

# command to run tests
env:
matrix:
- TOXENV=py-pytest28
- TOXENV=py-pytest29
- TOXENV=py-pytest30

matrix:
include:
- python: '2.7'
env: TOXENV=check
- python: '3.5'
- python: '3.6'
env: TOXENV=check
- python: '2.7'
env: TOXENV=benchmark
- python: '3.6'
env: TOXENV=benchmark

script:
- tox --recreate -e $TOXENV

Expand Down
50 changes: 50 additions & 0 deletions testing/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
Benchmarking and performance tests.
"""
import pytest
from pluggy import _MultiCall, HookImpl, HookspecMarker, HookimplMarker

hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")


def MC(methods, kwargs, firstresult=False):
hookfuncs = []
for method in methods:
f = HookImpl(None, "<temp>", method, method.example_impl)
hookfuncs.append(f)
return _MultiCall(hookfuncs, kwargs, {"firstresult": firstresult})


@hookimpl
def hook(arg1, arg2, arg3):
return arg1, arg2, arg3


@hookimpl(hookwrapper=True)
def wrapper(arg1, arg2, arg3):
yield


@pytest.fixture(
params=[0, 1, 10, 100],
ids="hooks={}".format,
)
def hooks(request):
return [hook for i in range(request.param)]


@pytest.fixture(
params=[0, 1, 10, 100],
ids="wrappers={}".format,
)
def wrappers(request):
return [wrapper for i in range(request.param)]


def inner_exec(methods):
return MC(methods, {'arg1': 1, 'arg2': 2, 'arg3': 3}).execute()


def test_hook_and_wrappers_speed(benchmark, hooks, wrappers):
benchmark(inner_exec, hooks + wrappers)
22 changes: 13 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
[tox]
envlist=check,py{26,27,34,35,py}-pytest{28,29,30}
envlist=check,py{26,27,34,35,36,py}-pytest{28,29,30}

[testenv]
commands= py.test {posargs:testing/}
commands=py.test {posargs:testing/}
deps=
pytest28: pytest~=2.8.0
pytest29: pytest~=2.9.0
pytest30: pytest~=3.0.0

[testenv:benchmark]
commands=py.test {posargs:testing/benchmark.py}
deps=
pytest
pytest-benchmark

[testenv:check]
deps =
flake8
restructuredtext_lint
commands =
restructuredtext_lint
commands =
flake8 pluggy.py setup.py testing
rst-lint CHANGELOG.rst README.rst


[testenv:docs]
deps =
sphinx
pygments

commands =
sphinx-build \
-b html \
{toxinidir}/docs {toxinidir}/build/html-docs

[pytest]
minversion=2.0
#--pyargs --doctest-modules --ignore=.tox
addopts= -rxsX
norecursedirs = .tox ja .hg .env*
addopts=-rxsX
norecursedirs=.tox ja .hg .env*

[flake8]
max-line-length = 99
max-line-length=99