Skip to content

Commit 8ec73dd

Browse files
committed
Profile numpy
1 parent f8c95db commit 8ec73dd

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
""" Profiles basic -jX functionality """
2+
# Copyright (c) 2020 Frank Harrison <[email protected]>
3+
4+
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
5+
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
6+
7+
# pylint: disable=protected-access,missing-function-docstring,no-self-use
8+
9+
import os
10+
11+
import pytest
12+
13+
from pylint.lint import Run
14+
from pylint.testutils import TestReporter as Reporter
15+
16+
17+
def _get_py_files(scanpath):
18+
assert os.path.exists(scanpath), "Dir not found %s" % scanpath
19+
20+
filepaths = []
21+
for _dirpath, dirnames, filenames in os.walk(scanpath):
22+
dirnames[:] = [dirname for dirname in dirnames if dirname != "__pycache__"]
23+
filepaths.extend(
24+
[filename for filename in filenames if filename.endswith(".py")]
25+
)
26+
return filepaths
27+
28+
29+
@pytest.mark.skipif(
30+
os.environ.get("PYTEST_PROFILE_NUMPY", False),
31+
reason="PYTEST_PROFILE_NUMPY, not set, assuming not a profile run",
32+
)
33+
class TestEstablishBaselineBenchmarks:
34+
""" Runs against numpy """
35+
36+
def test_run(self):
37+
38+
numpy_checkout_path = os.path.abspath(
39+
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
40+
)
41+
filepaths = _get_py_files(scanpath=numpy_checkout_path)
42+
43+
Run(filepaths, reporter=Reporter(), do_exit=False)
44+
45+
# assert runner.linter.msg_status == 0, (
46+
# "Expected no errors to be thrown: %s"
47+
# % pprint.pformat(runner.linter.reporter.messages)
48+
# )

tox.ini

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,28 @@ commands =
124124
python -Wi -m pytest --exitfirst --failed-first --benchmark-enable {toxinidir}/tests {posargs:} --profile-svg --benchmark-group-by="group" --benchmark-save-data --benchmark-autosave
125125

126126
changedir = {toxworkdir}
127+
128+
[testenv:profile_against_numpy]
129+
deps =
130+
https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0
131+
coverage<5.0
132+
gprof2dot
133+
isort
134+
mccabe
135+
pytest
136+
pytest-xdist
137+
pytest-profiling
138+
139+
setenv =
140+
PYTEST_PROFILE_NUMPY = 1
141+
142+
whitelist_externals =
143+
git
144+
mkdir
145+
146+
commands =
147+
mkdir -p {toxinidir}/.downstream_checkouts
148+
git clone [email protected]:numpy/numpy.git {toxinidir}/.downstream_checkouts/num_py
149+
python -Wi -m pytest --exitfirst --benchmark-disable {toxinidir}/tests/benchmark/test_profile_against_numpy.py --profile-svg
150+
151+
changedir = {toxworkdir}

0 commit comments

Comments
 (0)