Skip to content
Open
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
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- os: ubuntu-latest
python: pypy-3.11
experimental: false
- os: ubuntu-latest
python: pypy-3.12
experimental: false
- os: macos-latest
python: "3.15"
experimental: true
Expand Down
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ possible.
(source code, issues)
* `Download pyperformance on PyPI <https://pypi.python.org/pypi/pyperformance>`_

pyperformance is not tuned for PyPy yet: use the `PyPy benchmarks project
<https://foss.heptapod.net/pypy/benchmarks>`_ instead to measure PyPy
performances.
pyperformance supports PyPy, except for the ``dask`` benchmark, as its dependencies
do not support PyPy. See also the `PyPy benchmarks project <https://foss.heptapod.net/pypy/benchmarks>`_.

pyperformance is distributed under the MIT license.
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
Version 2.0.0 (unreleased)
--------------------------
* Add support for Python 3.15 and drop 3.10
* Add support for PyPy 3.12 (except the ``dask`` benchmark)
* Bump tornado to 6.6 (fixes ``BufferError`` on PyPy)
* Bump genshi to 0.7.12 (fixes ``TypeError`` on Python 3.15)
* Bump the pinned dependencies of most benchmarks to current releases,
Expand Down
24 changes: 14 additions & 10 deletions doc/custom_benchmarks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,21 +324,25 @@ All other PEP 621 fields are optional (e.g. ``requires-python = ">=3.8"``,
The ``[tool.pyperformance]`` Section
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

=============== ===== === === ===
field type R B F
=============== ===== === === ===
tool.name str X X
tool.tags [str] X
tool.extra_opts [str] X
tool.inherits file
tool.runscript file X
tool.datadir file X
=============== ===== === === ===
================================ ===== === === ===
field type R B F
================================ ===== === === ===
tool.name str X X
tool.tags [str] X
tool.extra_opts [str] X
tool.unsupported_implementations [str] X
tool.inherits file
tool.runscript file X
tool.datadir file X
================================ ===== === === ===

"R": required
"B": inferred from the inherited metadata
"F": inferred from filename

* tags: optional list of names to group benchmarks
* extra_opts: optional list of args to pass to ``tool.runscript``
* unsupported_implementations: optional list of Python implementations
(``sys.implementation.name``, e.g. ``"pypy"``) on which the benchmark
does not work; it is not selected when running on one of them
* runscript: the benchmark script to use instead of run_benchmark.py.
5 changes: 2 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ Other Python Benchmarks:
See also the `Python pyperf module
<https://pyperf.readthedocs.io/>`_ (used by pyperformance).

pyperformance is not tuned for PyPy yet: use the `PyPy benchmarks project
<https://foss.heptapod.net/pypy/benchmarks>`_ instead to measure PyPy
performances.
pyperformance supports PyPy, except for the ``dask`` benchmark, as its dependencies
do not support PyPy. See also the `PyPy benchmarks project <https://foss.heptapod.net/pypy/benchmarks>`_.

Image generated by bm_raytrace (pure Python raytrace):

Expand Down
5 changes: 5 additions & 0 deletions pyperformance/_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ def extra_opts(self):
def python(self):
return SpecifierSet(self._get_metadata_value("python", ""))

@property
def unsupported_implementations(self):
"""The names (sys.implementation.name) of the unsupported Pythons."""
return self._get_metadata_value("unsupported_implementations", ())

# Other metadata keys:
# * base
# * dependencies
Expand Down
13 changes: 13 additions & 0 deletions pyperformance/_benchmark_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"datadir": None,
"runscript": None,
"extra_opts": None,
"unsupported_implementations": None,
}


Expand All @@ -43,6 +44,7 @@
# datadir
# runscript
# extra_opts
# unsupported_implementations


def load_metadata(metafile, defaults=None):
Expand Down Expand Up @@ -235,6 +237,17 @@ def _resolve_value(field, value, rootdir):
raise TypeError(
f"extra_opts should be a list of strings, got {value!r}"
)
elif field == "unsupported_implementations":
if isinstance(value, str):
raise TypeError(
f"unsupported_implementations should be a list of strings, got {value!r}"
)
for name in value:
if not name or not isinstance(name, str):
raise TypeError(
f"unsupported_implementations should be a list of strings, got {value!r}"
)
value = [name.lower() for name in value]
else:
raise NotImplementedError(field)
return value
Expand Down
8 changes: 6 additions & 2 deletions pyperformance/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,17 @@ def parse_entry(o, s):
selected = []
info = _pythoninfo.get_info(python)
target_python_version = ".".join(map(str, info.sys.version_info[:3]))
target_implementation = info.sys.implementation.name.lower()
for bench in _benchmark_selections.iter_selections(manifest, parsed_infos):
if isinstance(bench, str):
logging.warning(f"no benchmark named {bench!r}")
continue
# Filter using the target interpreter, which may differ from the running Python.
if target_python_version in bench.python:
selected.append(bench)
if target_python_version not in bench.python:
continue
if target_implementation in bench.unsupported_implementations:
continue
selected.append(bench)

return selected

Expand Down
2 changes: 2 additions & 0 deletions pyperformance/data-files/benchmarks/bm_dask/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ dynamic = ["version"]

[tool.pyperformance]
name = "dask"
# cloudpickle and distributed do not support PyPy.
unsupported_implementations = ["pypy"]
28 changes: 27 additions & 1 deletion pyperformance/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ def test_target_python_version(self):
options = SimpleNamespace(
benchmarks="async_tree_eager", manifest=None, python="target-python"
)
info = SimpleNamespace(sys=SimpleNamespace(version_info=(3, 16, 0)))
info = SimpleNamespace(
sys=SimpleNamespace(
version_info=(3, 16, 0),
implementation=SimpleNamespace(name="cpython"),
)
)
with (
mock.patch.object(sys, "version_info", (3, 11, 0)),
mock.patch.object(_pythoninfo, "get_info", return_value=info) as get_info,
Expand All @@ -26,6 +31,27 @@ def test_target_python_version(self):
get_info.assert_called_once_with("target-python")
self.assertEqual([bench.name for bench in benchmarks], ["async_tree_eager"])

def test_unsupported_implementation(self):
options = SimpleNamespace(
benchmarks="dask,nbody", manifest=None, python="target-python"
)
for implementation, expected in [
("cpython", ["dask", "nbody"]),
("pypy", ["nbody"]),
]:
info = SimpleNamespace(
sys=SimpleNamespace(
version_info=(3, 12, 0),
implementation=SimpleNamespace(name=implementation),
)
)
with (
self.subTest(implementation),
mock.patch.object(_pythoninfo, "get_info", return_value=info),
):
benchmarks = cli._benchmarks_from_options(options)
self.assertEqual(sorted(bench.name for bench in benchmarks), expected)


class FullStackTests(tests.Functional, unittest.TestCase):
maxDiff = 80 * 100
Expand Down
Loading