pytest-codspeed 3.0.0b4__tar.gz → 3.1.0b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/PKG-INFO +22 -24
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/README.md +4 -3
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/pyproject.toml +43 -23
- pytest_codspeed-3.1.0b0/setup.cfg +4 -0
- pytest_codspeed-3.1.0b0/setup.py +53 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/__init__.py +2 -2
- pytest_codspeed-3.1.0b0/src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py +15 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed/instruments/valgrind/_wrapper/build.py +19 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/plugin.py +12 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed/py.typed +0 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed.egg-info/PKG-INFO +179 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed.egg-info/SOURCES.txt +27 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed.egg-info/dependency_links.txt +1 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed.egg-info/entry_points.txt +2 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed.egg-info/requires.txt +21 -0
- pytest_codspeed-3.1.0b0/src/pytest_codspeed.egg-info/top_level.txt +1 -0
- pytest_codspeed-3.1.0b0/tests/test_generate_semver.py +19 -0
- pytest_codspeed-3.1.0b0/tests/test_pytest_plugin.py +300 -0
- pytest_codspeed-3.1.0b0/tests/test_pytest_plugin_cpu_instrumentation.py +118 -0
- pytest_codspeed-3.1.0b0/tests/test_pytest_plugin_walltime.py +37 -0
- pytest_codspeed-3.1.0b0/tests/test_utils.py +34 -0
- pytest_codspeed-3.0.0b4/.gitignore +0 -166
- pytest_codspeed-3.0.0b4/src/pytest_codspeed/instruments/valgrind/_wrapper/.gitignore +0 -2
- pytest_codspeed-3.0.0b4/src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py +0 -40
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/LICENSE +0 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/instruments/__init__.py +0 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/instruments/valgrind/__init__.py +0 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c +0 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.h +0 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.pyi +0 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/instruments/walltime.py +0 -0
- {pytest_codspeed-3.0.0b4 → pytest_codspeed-3.1.0b0}/src/pytest_codspeed/utils.py +0 -0
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: pytest-codspeed
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.1.0b0
|
|
4
4
|
Summary: Pytest plugin to create CodSpeed benchmarks
|
|
5
|
-
Project-URL: Homepage, https://codspeed.io/
|
|
6
|
-
Project-URL: Documentation, https://docs.codspeed.io/
|
|
7
|
-
Project-URL: Source, https://github.com/CodSpeedHQ/pytest-codspeed
|
|
8
5
|
Author-email: Arthur Pastel <arthur@codspeed.io>
|
|
9
6
|
License: The MIT License (MIT)
|
|
10
7
|
|
|
@@ -27,15 +24,17 @@ License: The MIT License (MIT)
|
|
|
27
24
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
29
26
|
THE SOFTWARE.
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://codspeed.io/
|
|
29
|
+
Project-URL: Documentation, https://docs.codspeed.io/
|
|
30
|
+
Project-URL: Source, https://github.com/CodSpeedHQ/pytest-codspeed
|
|
31
|
+
Keywords: codspeed,benchmark,performance,pytest
|
|
32
32
|
Classifier: Development Status :: 5 - Production/Stable
|
|
33
33
|
Classifier: Framework :: Pytest
|
|
34
34
|
Classifier: Intended Audience :: Developers
|
|
35
35
|
Classifier: Intended Audience :: Information Technology
|
|
36
36
|
Classifier: License :: OSI Approved :: MIT License
|
|
37
37
|
Classifier: Programming Language :: Python :: 3
|
|
38
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
39
38
|
Classifier: Programming Language :: Python :: 3.9
|
|
40
39
|
Classifier: Programming Language :: Python :: 3.10
|
|
41
40
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -45,32 +44,30 @@ Classifier: Topic :: Software Development :: Testing
|
|
|
45
44
|
Classifier: Topic :: System :: Benchmark
|
|
46
45
|
Classifier: Topic :: Utilities
|
|
47
46
|
Classifier: Typing :: Typed
|
|
48
|
-
Requires-Python: >=3.
|
|
47
|
+
Requires-Python: >=3.9
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
49
|
Requires-Dist: cffi>=1.17.1
|
|
50
|
-
Requires-Dist: filelock>=3.12.2
|
|
51
|
-
Requires-Dist: importlib-metadata>=8.5.0; python_version < '3.10'
|
|
52
50
|
Requires-Dist: pytest>=3.8
|
|
53
51
|
Requires-Dist: rich>=13.8.1
|
|
54
|
-
Requires-Dist:
|
|
52
|
+
Requires-Dist: importlib-metadata>=8.5.0; python_version < "3.10"
|
|
55
53
|
Provides-Extra: build
|
|
56
|
-
Requires-Dist: semver>=3.0.2; extra ==
|
|
57
|
-
Provides-Extra: compat
|
|
58
|
-
Requires-Dist: pytest-benchmark~=4.0.0; extra == 'compat'
|
|
59
|
-
Requires-Dist: pytest-xdist~=3.6.1; extra == 'compat'
|
|
54
|
+
Requires-Dist: semver>=3.0.2; extra == "build"
|
|
60
55
|
Provides-Extra: lint
|
|
61
|
-
Requires-Dist: mypy~=1.11.2; extra ==
|
|
62
|
-
Requires-Dist: ruff~=0.6.5; extra ==
|
|
56
|
+
Requires-Dist: mypy~=1.11.2; extra == "lint"
|
|
57
|
+
Requires-Dist: ruff~=0.6.5; extra == "lint"
|
|
58
|
+
Provides-Extra: compat
|
|
59
|
+
Requires-Dist: pytest-benchmark~=5.0.0; extra == "compat"
|
|
60
|
+
Requires-Dist: pytest-xdist~=3.6.1; extra == "compat"
|
|
63
61
|
Provides-Extra: test
|
|
64
|
-
Requires-Dist: pytest
|
|
65
|
-
Requires-Dist: pytest~=
|
|
66
|
-
Description-Content-Type: text/markdown
|
|
62
|
+
Requires-Dist: pytest~=7.0; extra == "test"
|
|
63
|
+
Requires-Dist: pytest-cov~=4.0.0; extra == "test"
|
|
67
64
|
|
|
68
65
|
<div align="center">
|
|
69
66
|
<h1>pytest-codspeed</h1>
|
|
70
67
|
|
|
71
68
|
[](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
|
|
72
69
|
[](https://pypi.org/project/pytest-codspeed)
|
|
73
|
-

|
|
74
71
|
[](https://discord.com/invite/MxpaCfKSqF)
|
|
75
72
|
[](https://codspeed.io/CodSpeedHQ/pytest-codspeed)
|
|
76
73
|
|
|
@@ -80,7 +77,7 @@ Pytest plugin to create CodSpeed benchmarks
|
|
|
80
77
|
|
|
81
78
|
## Requirements
|
|
82
79
|
|
|
83
|
-
**Python**: 3.
|
|
80
|
+
**Python**: 3.9 and later
|
|
84
81
|
|
|
85
82
|
**pytest**: any recent version
|
|
86
83
|
|
|
@@ -155,7 +152,7 @@ You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run
|
|
|
155
152
|
Example workflow:
|
|
156
153
|
|
|
157
154
|
```yaml
|
|
158
|
-
name:
|
|
155
|
+
name: CodSpeed
|
|
159
156
|
|
|
160
157
|
on:
|
|
161
158
|
push:
|
|
@@ -165,6 +162,7 @@ on:
|
|
|
165
162
|
|
|
166
163
|
jobs:
|
|
167
164
|
benchmarks:
|
|
165
|
+
name: Run benchmarks
|
|
168
166
|
runs-on: ubuntu-latest
|
|
169
167
|
steps:
|
|
170
168
|
- uses: actions/checkout@v4
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
[](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
|
|
5
5
|
[](https://pypi.org/project/pytest-codspeed)
|
|
6
|
-

|
|
7
7
|
[](https://discord.com/invite/MxpaCfKSqF)
|
|
8
8
|
[](https://codspeed.io/CodSpeedHQ/pytest-codspeed)
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ Pytest plugin to create CodSpeed benchmarks
|
|
|
13
13
|
|
|
14
14
|
## Requirements
|
|
15
15
|
|
|
16
|
-
**Python**: 3.
|
|
16
|
+
**Python**: 3.9 and later
|
|
17
17
|
|
|
18
18
|
**pytest**: any recent version
|
|
19
19
|
|
|
@@ -88,7 +88,7 @@ You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run
|
|
|
88
88
|
Example workflow:
|
|
89
89
|
|
|
90
90
|
```yaml
|
|
91
|
-
name:
|
|
91
|
+
name: CodSpeed
|
|
92
92
|
|
|
93
93
|
on:
|
|
94
94
|
push:
|
|
@@ -98,6 +98,7 @@ on:
|
|
|
98
98
|
|
|
99
99
|
jobs:
|
|
100
100
|
benchmarks:
|
|
101
|
+
name: Run benchmarks
|
|
101
102
|
runs-on: ubuntu-latest
|
|
102
103
|
steps:
|
|
103
104
|
- uses: actions/checkout@v4
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["hatchling"]
|
|
3
|
-
build-backend = "hatchling.build"
|
|
4
|
-
|
|
5
1
|
[project.urls]
|
|
6
2
|
Homepage = "https://codspeed.io/"
|
|
7
3
|
Documentation = "https://docs.codspeed.io/"
|
|
@@ -13,7 +9,7 @@ dynamic = ["version"]
|
|
|
13
9
|
description = "Pytest plugin to create CodSpeed benchmarks"
|
|
14
10
|
readme = "README.md"
|
|
15
11
|
license = { file = "LICENSE" }
|
|
16
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.9"
|
|
17
13
|
authors = [{ name = "Arthur Pastel", email = "arthur@codspeed.io" }]
|
|
18
14
|
keywords = ["codspeed", "benchmark", "performance", "pytest"]
|
|
19
15
|
classifiers = [
|
|
@@ -23,7 +19,6 @@ classifiers = [
|
|
|
23
19
|
"Intended Audience :: Information Technology",
|
|
24
20
|
"License :: OSI Approved :: MIT License",
|
|
25
21
|
"Programming Language :: Python :: 3",
|
|
26
|
-
"Programming Language :: Python :: 3.8",
|
|
27
22
|
"Programming Language :: Python :: 3.9",
|
|
28
23
|
"Programming Language :: Python :: 3.10",
|
|
29
24
|
"Programming Language :: Python :: 3.11",
|
|
@@ -36,11 +31,7 @@ classifiers = [
|
|
|
36
31
|
]
|
|
37
32
|
dependencies = [
|
|
38
33
|
"cffi >= 1.17.1",
|
|
39
|
-
# cffi doesn't automatically install setuptools with python 3.12+
|
|
40
|
-
# cf https://github.com/python-cffi/cffi/releases/tag/v1.16.0
|
|
41
|
-
"setuptools; python_full_version >= '3.12.0'",
|
|
42
34
|
"pytest>=3.8",
|
|
43
|
-
"filelock >= 3.12.2",
|
|
44
35
|
"rich>=13.8.1",
|
|
45
36
|
"importlib-metadata>=8.5.0; python_version < '3.10'",
|
|
46
37
|
]
|
|
@@ -49,30 +40,59 @@ dependencies = [
|
|
|
49
40
|
build = ["semver>=3.0.2"]
|
|
50
41
|
lint = ["mypy ~= 1.11.2", "ruff ~= 0.6.5"]
|
|
51
42
|
compat = [
|
|
52
|
-
"pytest-benchmark ~=
|
|
43
|
+
"pytest-benchmark ~= 5.0.0",
|
|
53
44
|
"pytest-xdist ~= 3.6.1",
|
|
54
45
|
# "pytest-speed>=0.3.5",
|
|
55
46
|
]
|
|
56
47
|
test = ["pytest ~= 7.0", "pytest-cov ~= 4.0.0"]
|
|
48
|
+
|
|
57
49
|
[project.entry-points]
|
|
58
50
|
pytest11 = { codspeed = "pytest_codspeed.plugin" }
|
|
59
51
|
|
|
60
|
-
[
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
[build-system]
|
|
53
|
+
requires = ["setuptools >= 61", "cffi >= 1.17.1"]
|
|
54
|
+
build-backend = "setuptools.build_meta"
|
|
55
|
+
|
|
56
|
+
[tool.setuptools]
|
|
57
|
+
license-files = [] # Workaround of https://github.com/astral-sh/uv/issues/9513
|
|
63
58
|
|
|
64
|
-
[tool.
|
|
65
|
-
|
|
59
|
+
[tool.setuptools.dynamic]
|
|
60
|
+
version = { attr = "pytest_codspeed.__version__" }
|
|
66
61
|
|
|
67
|
-
[[tool.hatch.envs.test.matrix]]
|
|
68
|
-
python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
69
|
-
features = ["compat", "test"]
|
|
70
62
|
|
|
71
|
-
[tool.
|
|
72
|
-
|
|
63
|
+
[tool.bumpver]
|
|
64
|
+
current_version = "3.1.0-beta"
|
|
65
|
+
version_pattern = "MAJOR.MINOR.PATCH[-TAG]"
|
|
66
|
+
commit_message = "Release v{new_version} 🚀"
|
|
67
|
+
tag_message = "Release v{new_version} 🚀"
|
|
68
|
+
tag_scope = "default"
|
|
69
|
+
allow_dirty = false
|
|
70
|
+
pre_commit_hook = "./scripts/pre-release.sh"
|
|
71
|
+
post_commit_hook = "./scripts/post-release.sh"
|
|
72
|
+
commit = true
|
|
73
|
+
tag = false
|
|
74
|
+
push = false
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
[tool.bumpver.file_patterns]
|
|
78
|
+
"pyproject.toml" = ['current_version = "{version}"']
|
|
79
|
+
"src/pytest_codspeed/__init__.py" = [
|
|
80
|
+
'__version__ = "{pep440_version}"',
|
|
81
|
+
'__semver_version__ = "{version}"',
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.cibuildwheel]
|
|
85
|
+
build = "cp*manylinux*"
|
|
86
|
+
test-extras = ["build", "test", "compat"]
|
|
87
|
+
test-command = "pytest -v --ignore={project}/tests/benchmarks {project}/tests"
|
|
73
88
|
|
|
74
|
-
[tool.
|
|
75
|
-
|
|
89
|
+
[tool.cibuildwheel.linux]
|
|
90
|
+
environment = { PYTEST_CODSPEED_FORCE_EXTENSION_BUILD = "1", PYTEST_CODSPEED_FORCE_VALGRIND_TESTS = "1" }
|
|
91
|
+
archs = ["x86_64", "aarch64"]
|
|
92
|
+
manylinux-x86_64-image = "manylinux_2_28"
|
|
93
|
+
manylinux-aarch64-image = "manylinux_2_28"
|
|
94
|
+
before-all = "yum -y install valgrind-devel || apk add --upgrad valgrind-dev"
|
|
95
|
+
container-engine = { name = "docker", disable-host-mount = true }
|
|
76
96
|
|
|
77
97
|
[tool.mypy]
|
|
78
98
|
python_version = "3.12"
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import importlib.util
|
|
2
|
+
import os
|
|
3
|
+
import platform
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from setuptools import setup
|
|
7
|
+
|
|
8
|
+
build_path = (
|
|
9
|
+
Path(__file__).parent / "src/pytest_codspeed/instruments/valgrind/_wrapper/build.py"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
spec = importlib.util.spec_from_file_location("build", build_path)
|
|
13
|
+
assert spec is not None, "The spec should be initialized"
|
|
14
|
+
build = importlib.util.module_from_spec(spec)
|
|
15
|
+
assert spec.loader is not None, "The loader should be initialized"
|
|
16
|
+
spec.loader.exec_module(build)
|
|
17
|
+
|
|
18
|
+
system = platform.system()
|
|
19
|
+
current_arch = platform.machine()
|
|
20
|
+
|
|
21
|
+
print(f"System: {system} ({current_arch})")
|
|
22
|
+
|
|
23
|
+
IS_EXTENSION_BUILDABLE = system == "Linux" and current_arch in [
|
|
24
|
+
"x86_64",
|
|
25
|
+
"aarch64",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
IS_EXTENSION_REQUIRED = (
|
|
29
|
+
os.environ.get("PYTEST_CODSPEED_FORCE_EXTENSION_BUILD") is not None
|
|
30
|
+
)
|
|
31
|
+
if IS_EXTENSION_REQUIRED and not IS_EXTENSION_BUILDABLE:
|
|
32
|
+
raise ValueError(
|
|
33
|
+
"The extension is required but the current platform is not supported"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
ffi_extension = build.ffibuilder.distutils_extension()
|
|
38
|
+
ffi_extension.optional = not IS_EXTENSION_REQUIRED
|
|
39
|
+
|
|
40
|
+
print(
|
|
41
|
+
"CodSpeed native extension is "
|
|
42
|
+
+ ("required" if IS_EXTENSION_REQUIRED else "optional")
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
setup(
|
|
46
|
+
package_data={
|
|
47
|
+
"pytest_codspeed": [
|
|
48
|
+
"instruments/valgrind/_wrapper/*.h",
|
|
49
|
+
"instruments/valgrind/_wrapper/*.c",
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
ext_modules=[ffi_extension] if IS_EXTENSION_BUILDABLE else [],
|
|
53
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from .wrapper import lib as LibType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_lib() -> LibType:
|
|
10
|
+
try:
|
|
11
|
+
from .dist_callgrind_wrapper import lib # type: ignore
|
|
12
|
+
|
|
13
|
+
return lib
|
|
14
|
+
except Exception as e:
|
|
15
|
+
raise Exception("Failed to get a compiled wrapper") from e
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from cffi import FFI # type: ignore
|
|
4
|
+
|
|
5
|
+
wrapper_dir = Path(__file__).parent
|
|
6
|
+
|
|
7
|
+
ffibuilder = FFI()
|
|
8
|
+
|
|
9
|
+
ffibuilder.cdef((wrapper_dir / "wrapper.h").read_text())
|
|
10
|
+
|
|
11
|
+
ffibuilder.set_source(
|
|
12
|
+
"pytest_codspeed.instruments.valgrind._wrapper.dist_callgrind_wrapper",
|
|
13
|
+
'#include "wrapper.h"',
|
|
14
|
+
sources=["src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c"],
|
|
15
|
+
include_dirs=[str(wrapper_dir)],
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
if __name__ == "__main__":
|
|
19
|
+
ffibuilder.compile(verbose=True)
|
|
@@ -320,6 +320,18 @@ def pytest_sessionfinish(session: pytest.Session, exitstatus):
|
|
|
320
320
|
class BenchmarkFixture:
|
|
321
321
|
"""The fixture that can be used to benchmark a function."""
|
|
322
322
|
|
|
323
|
+
@property # type: ignore
|
|
324
|
+
def __class__(self):
|
|
325
|
+
# Bypass the pytest-benchmark fixture class check
|
|
326
|
+
# https://github.com/ionelmc/pytest-benchmark/commit/d6511e3474931feb4e862948128e0c389acfceec
|
|
327
|
+
if IS_PYTEST_BENCHMARK_INSTALLED:
|
|
328
|
+
from pytest_benchmark.fixture import (
|
|
329
|
+
BenchmarkFixture as PytestBenchmarkFixture,
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
return PytestBenchmarkFixture
|
|
333
|
+
return BenchmarkFixture
|
|
334
|
+
|
|
323
335
|
def __init__(self, request: pytest.FixtureRequest):
|
|
324
336
|
self.extra_info: dict = {}
|
|
325
337
|
|
|
File without changes
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pytest-codspeed
|
|
3
|
+
Version: 3.1.0b0
|
|
4
|
+
Summary: Pytest plugin to create CodSpeed benchmarks
|
|
5
|
+
Author-email: Arthur Pastel <arthur@codspeed.io>
|
|
6
|
+
License: The MIT License (MIT)
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2022 CodSpeed and contributors
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://codspeed.io/
|
|
29
|
+
Project-URL: Documentation, https://docs.codspeed.io/
|
|
30
|
+
Project-URL: Source, https://github.com/CodSpeedHQ/pytest-codspeed
|
|
31
|
+
Keywords: codspeed,benchmark,performance,pytest
|
|
32
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
33
|
+
Classifier: Framework :: Pytest
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: Intended Audience :: Information Technology
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
43
|
+
Classifier: Topic :: Software Development :: Testing
|
|
44
|
+
Classifier: Topic :: System :: Benchmark
|
|
45
|
+
Classifier: Topic :: Utilities
|
|
46
|
+
Classifier: Typing :: Typed
|
|
47
|
+
Requires-Python: >=3.9
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
Requires-Dist: cffi>=1.17.1
|
|
50
|
+
Requires-Dist: pytest>=3.8
|
|
51
|
+
Requires-Dist: rich>=13.8.1
|
|
52
|
+
Requires-Dist: importlib-metadata>=8.5.0; python_version < "3.10"
|
|
53
|
+
Provides-Extra: build
|
|
54
|
+
Requires-Dist: semver>=3.0.2; extra == "build"
|
|
55
|
+
Provides-Extra: lint
|
|
56
|
+
Requires-Dist: mypy~=1.11.2; extra == "lint"
|
|
57
|
+
Requires-Dist: ruff~=0.6.5; extra == "lint"
|
|
58
|
+
Provides-Extra: compat
|
|
59
|
+
Requires-Dist: pytest-benchmark~=5.0.0; extra == "compat"
|
|
60
|
+
Requires-Dist: pytest-xdist~=3.6.1; extra == "compat"
|
|
61
|
+
Provides-Extra: test
|
|
62
|
+
Requires-Dist: pytest~=7.0; extra == "test"
|
|
63
|
+
Requires-Dist: pytest-cov~=4.0.0; extra == "test"
|
|
64
|
+
|
|
65
|
+
<div align="center">
|
|
66
|
+
<h1>pytest-codspeed</h1>
|
|
67
|
+
|
|
68
|
+
[](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
|
|
69
|
+
[](https://pypi.org/project/pytest-codspeed)
|
|
70
|
+

|
|
71
|
+
[](https://discord.com/invite/MxpaCfKSqF)
|
|
72
|
+
[](https://codspeed.io/CodSpeedHQ/pytest-codspeed)
|
|
73
|
+
|
|
74
|
+
Pytest plugin to create CodSpeed benchmarks
|
|
75
|
+
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
## Requirements
|
|
79
|
+
|
|
80
|
+
**Python**: 3.9 and later
|
|
81
|
+
|
|
82
|
+
**pytest**: any recent version
|
|
83
|
+
|
|
84
|
+
## Installation
|
|
85
|
+
|
|
86
|
+
```shell
|
|
87
|
+
pip install pytest-codspeed
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Usage
|
|
91
|
+
|
|
92
|
+
### Creating benchmarks
|
|
93
|
+
|
|
94
|
+
Creating benchmarks with `pytest-codspeed` is compatible with the standard `pytest-benchmark` API. So if you already have benchmarks written with it, you can start using `pytest-codspeed` right away.
|
|
95
|
+
|
|
96
|
+
#### Marking a whole test function as a benchmark with `pytest.mark.benchmark`
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import pytest
|
|
100
|
+
from statistics import median
|
|
101
|
+
|
|
102
|
+
@pytest.mark.benchmark
|
|
103
|
+
def test_median_performance():
|
|
104
|
+
return median([1, 2, 3, 4, 5])
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Benchmarking selected lines of a test function with the `benchmark` fixture
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
import pytest
|
|
111
|
+
from statistics import mean
|
|
112
|
+
|
|
113
|
+
def test_mean_performance(benchmark):
|
|
114
|
+
# Precompute some data useful for the benchmark but that should not be
|
|
115
|
+
# included in the benchmark time
|
|
116
|
+
data = [1, 2, 3, 4, 5]
|
|
117
|
+
|
|
118
|
+
# Benchmark the execution of the function
|
|
119
|
+
benchmark(lambda: mean(data))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_mean_and_median_performance(benchmark):
|
|
123
|
+
# Precompute some data useful for the benchmark but that should not be
|
|
124
|
+
# included in the benchmark time
|
|
125
|
+
data = [1, 2, 3, 4, 5]
|
|
126
|
+
|
|
127
|
+
# Benchmark the execution of the function:
|
|
128
|
+
# The `@benchmark` decorator will automatically call the function and
|
|
129
|
+
# measure its execution
|
|
130
|
+
@benchmark
|
|
131
|
+
def bench():
|
|
132
|
+
mean(data)
|
|
133
|
+
median(data)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Running benchmarks
|
|
137
|
+
|
|
138
|
+
#### Testing the benchmarks locally
|
|
139
|
+
|
|
140
|
+
If you want to run only the benchmarks tests locally, you can use the `--codspeed` pytest flag:
|
|
141
|
+
|
|
142
|
+
```shell
|
|
143
|
+
pytest tests/ --codspeed
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
> **Note:** Running `pytest-codspeed` locally will not produce any performance reporting. It's only useful for making sure that your benchmarks are working as expected. If you want to get performance reporting, you should run the benchmarks in your CI.
|
|
147
|
+
|
|
148
|
+
#### In your CI
|
|
149
|
+
|
|
150
|
+
You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run the benchmarks in Github Actions and upload the results to CodSpeed.
|
|
151
|
+
|
|
152
|
+
Example workflow:
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
name: CodSpeed
|
|
156
|
+
|
|
157
|
+
on:
|
|
158
|
+
push:
|
|
159
|
+
branches:
|
|
160
|
+
- "main" # or "master"
|
|
161
|
+
pull_request:
|
|
162
|
+
|
|
163
|
+
jobs:
|
|
164
|
+
benchmarks:
|
|
165
|
+
name: Run benchmarks
|
|
166
|
+
runs-on: ubuntu-latest
|
|
167
|
+
steps:
|
|
168
|
+
- uses: actions/checkout@v4
|
|
169
|
+
- uses: actions/setup-python@v5
|
|
170
|
+
with:
|
|
171
|
+
python-version: "3.12"
|
|
172
|
+
- name: Install dependencies
|
|
173
|
+
run: pip install -r requirements.txt
|
|
174
|
+
- name: Run benchmarks
|
|
175
|
+
uses: CodSpeedHQ/action@v3
|
|
176
|
+
with:
|
|
177
|
+
token: ${{ secrets.CODSPEED_TOKEN }}
|
|
178
|
+
run: pytest tests/ --codspeed
|
|
179
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
src/pytest_codspeed/__init__.py
|
|
6
|
+
src/pytest_codspeed/plugin.py
|
|
7
|
+
src/pytest_codspeed/py.typed
|
|
8
|
+
src/pytest_codspeed/utils.py
|
|
9
|
+
src/pytest_codspeed.egg-info/PKG-INFO
|
|
10
|
+
src/pytest_codspeed.egg-info/SOURCES.txt
|
|
11
|
+
src/pytest_codspeed.egg-info/dependency_links.txt
|
|
12
|
+
src/pytest_codspeed.egg-info/entry_points.txt
|
|
13
|
+
src/pytest_codspeed.egg-info/requires.txt
|
|
14
|
+
src/pytest_codspeed.egg-info/top_level.txt
|
|
15
|
+
src/pytest_codspeed/instruments/__init__.py
|
|
16
|
+
src/pytest_codspeed/instruments/walltime.py
|
|
17
|
+
src/pytest_codspeed/instruments/valgrind/__init__.py
|
|
18
|
+
src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py
|
|
19
|
+
src/pytest_codspeed/instruments/valgrind/_wrapper/build.py
|
|
20
|
+
src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c
|
|
21
|
+
src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.h
|
|
22
|
+
src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.pyi
|
|
23
|
+
tests/test_generate_semver.py
|
|
24
|
+
tests/test_pytest_plugin.py
|
|
25
|
+
tests/test_pytest_plugin_cpu_instrumentation.py
|
|
26
|
+
tests/test_pytest_plugin_walltime.py
|
|
27
|
+
tests/test_utils.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
cffi>=1.17.1
|
|
2
|
+
pytest>=3.8
|
|
3
|
+
rich>=13.8.1
|
|
4
|
+
|
|
5
|
+
[:python_version < "3.10"]
|
|
6
|
+
importlib-metadata>=8.5.0
|
|
7
|
+
|
|
8
|
+
[build]
|
|
9
|
+
semver>=3.0.2
|
|
10
|
+
|
|
11
|
+
[compat]
|
|
12
|
+
pytest-benchmark~=5.0.0
|
|
13
|
+
pytest-xdist~=3.6.1
|
|
14
|
+
|
|
15
|
+
[lint]
|
|
16
|
+
mypy~=1.11.2
|
|
17
|
+
ruff~=0.6.5
|
|
18
|
+
|
|
19
|
+
[test]
|
|
20
|
+
pytest~=7.0
|
|
21
|
+
pytest-cov~=4.0.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pytest_codspeed
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from generate_semver import pypi_version_to_semver
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_pypi_version_to_semver_valid():
|
|
6
|
+
# Test cases for valid PyPI version strings
|
|
7
|
+
assert pypi_version_to_semver("1.0.0") == "1.0.0"
|
|
8
|
+
assert pypi_version_to_semver("1.0.0a1") == "1.0.0-a1"
|
|
9
|
+
assert pypi_version_to_semver("1.0.0b1") == "1.0.0-b1"
|
|
10
|
+
assert pypi_version_to_semver("1.0.0rc1") == "1.0.0-rc1"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_pypi_version_to_semver_invalid():
|
|
14
|
+
# Test cases for invalid PyPI version strings that should raise ValueError
|
|
15
|
+
with pytest.raises(ValueError, match="Can't convert an epoch to semver"):
|
|
16
|
+
pypi_version_to_semver("1!1.0.0")
|
|
17
|
+
|
|
18
|
+
with pytest.raises(ValueError, match="Can't convert a post part to semver"):
|
|
19
|
+
pypi_version_to_semver("1.0.0.post")
|