pyperf 2.6.3__tar.gz → 2.7.0__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.
- {pyperf-2.6.3/pyperf.egg-info → pyperf-2.7.0}/PKG-INFO +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/analyze.rst +12 -6
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/api.rst +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/changelog.rst +13 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/conf.py +8 -9
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples.rst +3 -2
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/index.rst +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/__init__.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_bench.py +5 -5
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_cli.py +2 -2
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_collect_metadata.py +7 -2
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_compare.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_linux_memory.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_manager.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_metadata.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_runner.py +2 -2
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_system.py +18 -13
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_utils.py +5 -4
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_worker.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/__init__.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/replay.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_metadata.py +2 -2
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_perf_cli.py +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0/pyperf.egg-info}/PKG-INFO +1 -1
- {pyperf-2.6.3 → pyperf-2.7.0}/pyproject.toml +7 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/tox.ini +3 -9
- {pyperf-2.6.3 → pyperf-2.7.0}/COPYING +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/MANIFEST.in +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/README.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/TODO.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/Makefile +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/cli.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/developer_guide.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/bench_async_func.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/bench_async_func_with_loop_factory.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/bench_command.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/bench_func.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/bench_time_func.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/bench_timeit.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/export_csv.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/hist_scipy.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/examples/plot.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/hist_scipy_telco.png +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/make.bat +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/outliers.json.gz +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/py2.json.gz +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/py3.json.gz +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/run_benchmark.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/runner.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/system.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/timeit_strip.json.gz +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/doc/user_guide.rst +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/__main__.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_command.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_cpu_utils.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_formatter.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_process_time.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_psutil_memory.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_timeit.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_timeit_cli.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/_win_memory.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/mult_list_bench.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/mult_list_py36.json +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/mult_list_py36_tags.json +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/mult_list_py37.json +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/mult_list_py37_tags.json +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/mult_list_py38.json +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/telco.json +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_bench.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_cli.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_examples.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_misc.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_runner.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_system.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_timeit.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/test_utils.py +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf/tests/track_memory.json +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf.egg-info/SOURCES.txt +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf.egg-info/dependency_links.txt +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf.egg-info/entry_points.txt +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf.egg-info/requires.txt +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/pyperf.egg-info/top_level.txt +0 -0
- {pyperf-2.6.3 → pyperf-2.7.0}/setup.cfg +0 -0
|
@@ -223,9 +223,15 @@ two-sample, two-tailed t-test
|
|
|
223
223
|
|
|
224
224
|
Render a table using ``--table`` option::
|
|
225
225
|
|
|
226
|
-
$ python3 -m pyperf compare_to
|
|
227
|
-
|
|
228
|
-
| Benchmark
|
|
229
|
-
|
|
230
|
-
|
|
|
231
|
-
|
|
226
|
+
$ python3 -m pyperf compare_to mult_list_py36.json mult_list_py38.json --table
|
|
227
|
+
+----------------+----------------+-----------------------+
|
|
228
|
+
| Benchmark | mult_list_py36 | mult_list_py38 |
|
|
229
|
+
+================+================+=======================+
|
|
230
|
+
| [1,2]*1000 | 3.70 us | 3.18 us: 1.16x faster |
|
|
231
|
+
+----------------+----------------+-----------------------+
|
|
232
|
+
| [1,2,3]*1000 | 4.61 us | 4.17 us: 1.11x faster |
|
|
233
|
+
+----------------+----------------+-----------------------+
|
|
234
|
+
| Geometric mean | (ref) | 1.09x faster |
|
|
235
|
+
+----------------+----------------+-----------------------+
|
|
236
|
+
|
|
237
|
+
Benchmark hidden because not significant (1): [1]*1000
|
|
@@ -679,7 +679,7 @@ Benchmark:
|
|
|
679
679
|
* ``inner_loops`` (``int >= 1``): number of inner-loops of the benchmark (``int``)
|
|
680
680
|
* ``timer``: Implementation of ``time.perf_counter()``, and also resolution if
|
|
681
681
|
available
|
|
682
|
-
* ``tags``: (list of str, optional): A list of tags associated with the benchmark. If provided, the results output will be
|
|
682
|
+
* ``tags``: (list of str, optional): A list of tags associated with the benchmark. If provided, the results output will be aggregated by each tag.
|
|
683
683
|
|
|
684
684
|
Python metadata:
|
|
685
685
|
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
Version 2.7.0 (2024-05-18)
|
|
5
|
+
---------------------------
|
|
6
|
+
|
|
7
|
+
* Fix logic in MSR availability test.
|
|
8
|
+
Patch by Mike Droettboom.
|
|
9
|
+
* Disable tuning TurboBoost setting on non-Intel device.
|
|
10
|
+
Patch by Mike Droettboom.
|
|
11
|
+
* Include CONFIG_ARGS in Metadata.
|
|
12
|
+
Patch by Jeff Glass.
|
|
13
|
+
* Support environment variables PYTHON_GIL / PYTHON_CPU_COUNT.
|
|
14
|
+
Patch by Donghee Na.
|
|
15
|
+
|
|
4
16
|
Version 2.6.3 (2024-03-05)
|
|
5
17
|
---------------------------
|
|
6
18
|
|
|
@@ -88,7 +100,7 @@ Version 2.1.0 (2021-01-14)
|
|
|
88
100
|
* The :ref:`compare_to command <compare_to_cmd>` no longer displays
|
|
89
101
|
percentages: display less numbers to make the output easier to read. Also,
|
|
90
102
|
percentage were almost the same values than the xxx faster or xxx slower
|
|
91
|
-
values, but rounded
|
|
103
|
+
values, but rounded differently which introduced confusion.
|
|
92
104
|
* Project moved to https://github.com/psf/pyperf/
|
|
93
105
|
* system command now only emits a warning rather than failing with a hard error
|
|
94
106
|
if it fails to get or set the frequency of a CPU.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
#
|
|
3
2
|
# pyperf documentation build configuration file, created by
|
|
4
3
|
# sphinx-quickstart on Wed Jun 1 15:28:03 2016.
|
|
@@ -42,16 +41,16 @@ source_suffix = '.rst'
|
|
|
42
41
|
master_doc = 'index'
|
|
43
42
|
|
|
44
43
|
# General information about the project.
|
|
45
|
-
project =
|
|
46
|
-
copyright =
|
|
47
|
-
author =
|
|
44
|
+
project = 'pyperf'
|
|
45
|
+
copyright = '2016, Victor Stinner'
|
|
46
|
+
author = 'Victor Stinner'
|
|
48
47
|
|
|
49
48
|
# The version info for the project you're documenting, acts as replacement for
|
|
50
49
|
# |version| and |release|, also used in various other places throughout the
|
|
51
50
|
# built documents.
|
|
52
51
|
#
|
|
53
52
|
# The short X.Y version.
|
|
54
|
-
version = release = '2.
|
|
53
|
+
version = release = '2.7.0'
|
|
55
54
|
|
|
56
55
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
57
56
|
# for a list of supported languages.
|
|
@@ -216,8 +215,8 @@ latex_elements = {
|
|
|
216
215
|
# (source start file, target name, title,
|
|
217
216
|
# author, documentclass [howto, manual, or own class]).
|
|
218
217
|
latex_documents = [
|
|
219
|
-
(master_doc, 'pyperf.tex',
|
|
220
|
-
|
|
218
|
+
(master_doc, 'pyperf.tex', 'pyperf Documentation',
|
|
219
|
+
'Victor Stinner', 'manual'),
|
|
221
220
|
]
|
|
222
221
|
|
|
223
222
|
# The name of an image file (relative to this directory) to place at the top of
|
|
@@ -246,7 +245,7 @@ latex_documents = [
|
|
|
246
245
|
# One entry per manual page. List of tuples
|
|
247
246
|
# (source start file, name, description, authors, manual section).
|
|
248
247
|
man_pages = [
|
|
249
|
-
(master_doc, 'pyperf',
|
|
248
|
+
(master_doc, 'pyperf', 'pyperf Documentation',
|
|
250
249
|
[author], 1)
|
|
251
250
|
]
|
|
252
251
|
|
|
@@ -260,7 +259,7 @@ man_pages = [
|
|
|
260
259
|
# (source start file, target name, title, author,
|
|
261
260
|
# dir menu entry, description, category)
|
|
262
261
|
texinfo_documents = [
|
|
263
|
-
(master_doc, 'pyperf',
|
|
262
|
+
(master_doc, 'pyperf', 'pyperf Documentation',
|
|
264
263
|
author, 'pyperf', 'One line description of project.',
|
|
265
264
|
'Miscellaneous'),
|
|
266
265
|
]
|
|
@@ -31,8 +31,9 @@ bench_async_func() method
|
|
|
31
31
|
timeit() method
|
|
32
32
|
---------------
|
|
33
33
|
|
|
34
|
-
Benchmark using the :meth:`Runner.timeit` method to performance of
|
|
35
|
-
sorted list of 1000 numbers using a ``key`` function (which does
|
|
34
|
+
Benchmark using the :meth:`Runner.timeit` method to measure the performance of
|
|
35
|
+
sorting a sorted list of 1000 numbers using a ``key`` function (which does
|
|
36
|
+
nothing):
|
|
36
37
|
|
|
37
38
|
.. literalinclude:: examples/bench_timeit.py
|
|
38
39
|
|
|
@@ -86,7 +86,7 @@ def _cached_attr(func):
|
|
|
86
86
|
return method
|
|
87
87
|
|
|
88
88
|
|
|
89
|
-
class Run
|
|
89
|
+
class Run:
|
|
90
90
|
# Run is immutable, so it can be shared/exchanged between two benchmarks
|
|
91
91
|
|
|
92
92
|
__slots__ = ('_warmups', '_values', '_metadata')
|
|
@@ -319,7 +319,7 @@ class Run(object):
|
|
|
319
319
|
return self._replace(metadata=metadata2)
|
|
320
320
|
|
|
321
321
|
|
|
322
|
-
class Benchmark
|
|
322
|
+
class Benchmark:
|
|
323
323
|
def __init__(self, runs):
|
|
324
324
|
self._runs = [] # list of Run objects
|
|
325
325
|
self._clear_runs_cache()
|
|
@@ -627,7 +627,7 @@ class Benchmark(object):
|
|
|
627
627
|
self._replace_runs(new_runs)
|
|
628
628
|
|
|
629
629
|
|
|
630
|
-
class BenchmarkSuite
|
|
630
|
+
class BenchmarkSuite:
|
|
631
631
|
def __init__(self, benchmarks, filename=None):
|
|
632
632
|
if not benchmarks:
|
|
633
633
|
raise ValueError("benchmarks must be a non-empty "
|
|
@@ -727,7 +727,7 @@ class BenchmarkSuite(object):
|
|
|
727
727
|
if isinstance(filename, bytes):
|
|
728
728
|
suffix = b'.gz'
|
|
729
729
|
else:
|
|
730
|
-
suffix =
|
|
730
|
+
suffix = '.gz'
|
|
731
731
|
|
|
732
732
|
if filename.endswith(suffix):
|
|
733
733
|
# Use lazy import to limit imports on 'import pyperf'
|
|
@@ -770,7 +770,7 @@ class BenchmarkSuite(object):
|
|
|
770
770
|
if isinstance(filename, bytes):
|
|
771
771
|
suffix = b'.gz'
|
|
772
772
|
else:
|
|
773
|
-
suffix =
|
|
773
|
+
suffix = '.gz'
|
|
774
774
|
|
|
775
775
|
if not replace and os.path.exists(filename):
|
|
776
776
|
raise OSError(errno.EEXIST, "File already exists")
|
|
@@ -604,7 +604,7 @@ def catch_broken_pipe_error(file=None):
|
|
|
604
604
|
# was closed by the consumer
|
|
605
605
|
for file in files:
|
|
606
606
|
file.flush()
|
|
607
|
-
except
|
|
607
|
+
except OSError as exc:
|
|
608
608
|
if exc.errno != errno.EPIPE:
|
|
609
609
|
raise
|
|
610
610
|
# got a broken pipe error: ignore it
|
|
@@ -615,5 +615,5 @@ def catch_broken_pipe_error(file=None):
|
|
|
615
615
|
for file in files:
|
|
616
616
|
try:
|
|
617
617
|
file.close()
|
|
618
|
-
except
|
|
618
|
+
except OSError:
|
|
619
619
|
pass
|
|
@@ -111,6 +111,11 @@ def collect_python_metadata(metadata):
|
|
|
111
111
|
cflags = normalize_text(cflags)
|
|
112
112
|
metadata['python_cflags'] = cflags
|
|
113
113
|
|
|
114
|
+
config_args = sysconfig.get_config_var('CONFIG_ARGS')
|
|
115
|
+
if config_args:
|
|
116
|
+
config_args = normalize_text(config_args)
|
|
117
|
+
metadata['python_config_args'] = config_args
|
|
118
|
+
|
|
114
119
|
# GC disabled?
|
|
115
120
|
try:
|
|
116
121
|
import gc
|
|
@@ -131,7 +136,7 @@ def read_proc(path):
|
|
|
131
136
|
with open_text(path) as fp:
|
|
132
137
|
for line in fp:
|
|
133
138
|
yield line.rstrip()
|
|
134
|
-
except
|
|
139
|
+
except OSError:
|
|
135
140
|
return
|
|
136
141
|
|
|
137
142
|
|
|
@@ -327,7 +332,7 @@ def get_cpu_temperature(path, cpu_temp):
|
|
|
327
332
|
|
|
328
333
|
try:
|
|
329
334
|
temp_label = read_first_line(template % 'label', error=True)
|
|
330
|
-
except
|
|
335
|
+
except OSError:
|
|
331
336
|
break
|
|
332
337
|
|
|
333
338
|
temp_input = read_first_line(template % 'input', error=True)
|
|
@@ -69,7 +69,7 @@ class CLIError(Exception):
|
|
|
69
69
|
class Runner:
|
|
70
70
|
_created = set()
|
|
71
71
|
|
|
72
|
-
# Default parameters are chosen to have
|
|
72
|
+
# Default parameters are chosen to have approximately a run of 0.5 second
|
|
73
73
|
# and so a total duration of 5 seconds by default
|
|
74
74
|
def __init__(self, values=None, processes=None,
|
|
75
75
|
loops=0, min_time=0.1, metadata=None,
|
|
@@ -85,7 +85,7 @@ class Runner:
|
|
|
85
85
|
pass
|
|
86
86
|
|
|
87
87
|
# Watchdog: ensure that only once instance of Runner (or a Runner
|
|
88
|
-
# subclass) is created per process to prevent bad
|
|
88
|
+
# subclass) is created per process to prevent bad surprises
|
|
89
89
|
cls = self.__class__
|
|
90
90
|
key = id(cls)
|
|
91
91
|
if key in cls._created:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import errno
|
|
2
2
|
import os.path
|
|
3
|
+
import platform
|
|
3
4
|
import re
|
|
4
5
|
import struct
|
|
5
6
|
import subprocess
|
|
@@ -74,7 +75,7 @@ def use_intel_pstate():
|
|
|
74
75
|
return (scaling_driver == 'intel_pstate')
|
|
75
76
|
|
|
76
77
|
|
|
77
|
-
class Operation
|
|
78
|
+
class Operation:
|
|
78
79
|
@staticmethod
|
|
79
80
|
def available():
|
|
80
81
|
return True
|
|
@@ -107,7 +108,7 @@ class Operation(object):
|
|
|
107
108
|
def read_first_line(self, path):
|
|
108
109
|
try:
|
|
109
110
|
return read_first_line(path, error=True)
|
|
110
|
-
except
|
|
111
|
+
except OSError as exc:
|
|
111
112
|
self.check_permission_error(exc)
|
|
112
113
|
return ''
|
|
113
114
|
|
|
@@ -125,7 +126,11 @@ class TurboBoostMSR(Operation):
|
|
|
125
126
|
|
|
126
127
|
@staticmethod
|
|
127
128
|
def available():
|
|
128
|
-
return (
|
|
129
|
+
return (
|
|
130
|
+
OS_LINUX and
|
|
131
|
+
not use_intel_pstate() and
|
|
132
|
+
platform.machine() in ('x86', 'x86_64', 'amd64')
|
|
133
|
+
)
|
|
129
134
|
|
|
130
135
|
def __init__(self, system):
|
|
131
136
|
Operation.__init__(self, 'Turbo Boost (MSR)', system)
|
|
@@ -219,7 +224,7 @@ class TurboBoostMSR(Operation):
|
|
|
219
224
|
os.write(fd, data)
|
|
220
225
|
finally:
|
|
221
226
|
os.close(fd)
|
|
222
|
-
except
|
|
227
|
+
except OSError as exc:
|
|
223
228
|
self.check_permission_error(exc)
|
|
224
229
|
self.error("Failed to write %#x into MSR %#x using %s: %s"
|
|
225
230
|
% (value, reg_num, path, exc))
|
|
@@ -308,7 +313,7 @@ class TurboBoostIntelPstate(Operation):
|
|
|
308
313
|
content = '0' if enable else '1'
|
|
309
314
|
try:
|
|
310
315
|
write_text(self.path, content)
|
|
311
|
-
except
|
|
316
|
+
except OSError as exc:
|
|
312
317
|
# don't log a permission error if the user is root: permission
|
|
313
318
|
# error as root means that Turbo Boost is disabled in the BIOS
|
|
314
319
|
if not is_root():
|
|
@@ -376,7 +381,7 @@ class CPUGovernorIntelPstate(Operation):
|
|
|
376
381
|
return
|
|
377
382
|
try:
|
|
378
383
|
write_text(self.path, new_governor)
|
|
379
|
-
except
|
|
384
|
+
except OSError as exc:
|
|
380
385
|
self.error("Failed to set the CPU scaling governor: %s" % exc)
|
|
381
386
|
else:
|
|
382
387
|
self.log_action("CPU scaling governor set to %s" % new_governor)
|
|
@@ -384,7 +389,7 @@ class CPUGovernorIntelPstate(Operation):
|
|
|
384
389
|
|
|
385
390
|
class LinuxScheduler(Operation):
|
|
386
391
|
"""
|
|
387
|
-
Check isolcpus=cpus and rcu_nocbs=cpus
|
|
392
|
+
Check isolcpus=cpus and rcu_nocbs=cpus parameters of the Linux kernel
|
|
388
393
|
command line.
|
|
389
394
|
"""
|
|
390
395
|
|
|
@@ -495,7 +500,7 @@ class ASLR(Operation):
|
|
|
495
500
|
|
|
496
501
|
try:
|
|
497
502
|
write_text(self.path, new_value)
|
|
498
|
-
except
|
|
503
|
+
except OSError as exc:
|
|
499
504
|
self.check_permission_error(exc)
|
|
500
505
|
self.error("Failed to write into %s: %s" % (self.path, exc))
|
|
501
506
|
else:
|
|
@@ -552,7 +557,7 @@ class CPUFrequency(Operation):
|
|
|
552
557
|
try:
|
|
553
558
|
with open(filename, "rb") as fp:
|
|
554
559
|
return fp.readline()
|
|
555
|
-
except
|
|
560
|
+
except OSError as exc:
|
|
556
561
|
self.check_permission_error(exc)
|
|
557
562
|
return None
|
|
558
563
|
|
|
@@ -579,7 +584,7 @@ class CPUFrequency(Operation):
|
|
|
579
584
|
filename = os.path.join(cpu_path, "scaling_min_freq")
|
|
580
585
|
try:
|
|
581
586
|
return self.write_freq(filename, freq)
|
|
582
|
-
except
|
|
587
|
+
except OSError as exc:
|
|
583
588
|
self.check_permission_error(exc)
|
|
584
589
|
self.error("Unable to write scaling_max_freq of CPU %s: %s"
|
|
585
590
|
% (cpu, exc))
|
|
@@ -768,7 +773,7 @@ class IRQAffinity(Operation):
|
|
|
768
773
|
mask = format_cpus_as_mask(new_affinity)
|
|
769
774
|
try:
|
|
770
775
|
write_text(self.default_affinity_path, mask)
|
|
771
|
-
except
|
|
776
|
+
except OSError as exc:
|
|
772
777
|
self.check_permission_error(exc)
|
|
773
778
|
self.error("Failed to write %r into %s: %s"
|
|
774
779
|
% (mask, self.default_affinity_path, exc))
|
|
@@ -782,7 +787,7 @@ class IRQAffinity(Operation):
|
|
|
782
787
|
try:
|
|
783
788
|
write_text(path, mask)
|
|
784
789
|
return True
|
|
785
|
-
except
|
|
790
|
+
except OSError as exc:
|
|
786
791
|
self.check_permission_error(exc)
|
|
787
792
|
# EIO means that the IRQ doesn't support SMP affinity:
|
|
788
793
|
# ignore the error
|
|
@@ -937,7 +942,7 @@ class PerfEvent(Operation):
|
|
|
937
942
|
|
|
938
943
|
try:
|
|
939
944
|
write_text(self.path, str(new_rate))
|
|
940
|
-
except
|
|
945
|
+
except OSError as exc:
|
|
941
946
|
self.check_permission_error(exc)
|
|
942
947
|
self.error("Failed to write into %s: %s" % (self.path, exc))
|
|
943
948
|
else:
|
|
@@ -155,7 +155,7 @@ def read_first_line(path, error=False):
|
|
|
155
155
|
with open_text(path) as fp:
|
|
156
156
|
line = fp.readline()
|
|
157
157
|
return line.rstrip()
|
|
158
|
-
except
|
|
158
|
+
except OSError:
|
|
159
159
|
if error:
|
|
160
160
|
raise
|
|
161
161
|
else:
|
|
@@ -266,8 +266,9 @@ def create_environ(inherit_environ, locale, copy_all):
|
|
|
266
266
|
if copy_all:
|
|
267
267
|
return os.environ
|
|
268
268
|
env = {}
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
copy_env = ["PATH", "HOME", "TEMP", "COMSPEC", "SystemRoot", "SystemDrive",
|
|
270
|
+
# Python specific variables
|
|
271
|
+
"PYTHONPATH", "PYTHON_CPU_COUNT", "PYTHON_GIL"]
|
|
271
272
|
if locale:
|
|
272
273
|
copy_env.extend(('LANG', 'LC_ADDRESS', 'LC_ALL', 'LC_COLLATE',
|
|
273
274
|
'LC_CTYPE', 'LC_IDENTIFICATION', 'LC_MEASUREMENT',
|
|
@@ -282,7 +283,7 @@ def create_environ(inherit_environ, locale, copy_all):
|
|
|
282
283
|
return env
|
|
283
284
|
|
|
284
285
|
|
|
285
|
-
class _Pipe
|
|
286
|
+
class _Pipe:
|
|
286
287
|
_OPEN_MODE = "r"
|
|
287
288
|
|
|
288
289
|
def __init__(self, fd):
|
|
@@ -55,7 +55,7 @@ def temporary_directory():
|
|
|
55
55
|
def benchmark_as_json(benchmark, compact=True):
|
|
56
56
|
with temporary_file() as tmp_name:
|
|
57
57
|
benchmark.dump(tmp_name, compact=compact)
|
|
58
|
-
with
|
|
58
|
+
with open(tmp_name, 'r', encoding='utf-8') as tmp:
|
|
59
59
|
return tmp.read()
|
|
60
60
|
|
|
61
61
|
|
|
@@ -159,7 +159,7 @@ class CpuFunctionsTests(unittest.TestCase):
|
|
|
159
159
|
elif filename.startswith('/sys/devices/system/cpu/nohz_full'):
|
|
160
160
|
data = nohz_full
|
|
161
161
|
elif filename.startswith('/sys/devices/system/cpu/cpu2'):
|
|
162
|
-
raise
|
|
162
|
+
raise OSError
|
|
163
163
|
elif filename == '/sys/devices/system/cpu/cpuidle/current_driver':
|
|
164
164
|
data = 'IDLE_DRV\n'
|
|
165
165
|
else:
|
|
@@ -194,7 +194,7 @@ class CpuFunctionsTests(unittest.TestCase):
|
|
|
194
194
|
elif filename == '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor':
|
|
195
195
|
data = 'GOVERNOR\n'
|
|
196
196
|
elif filename.startswith('/sys/devices/system/cpu/cpu2'):
|
|
197
|
-
raise
|
|
197
|
+
raise OSError
|
|
198
198
|
else:
|
|
199
199
|
raise ValueError("unexpect open: %r" % filename)
|
|
200
200
|
return io.StringIO(data)
|
|
@@ -61,3 +61,10 @@ packages = ["pyperf", "pyperf.tests"]
|
|
|
61
61
|
|
|
62
62
|
[tool.setuptools.dynamic]
|
|
63
63
|
version = {attr = "pyperf.__version__"}
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint]
|
|
66
|
+
extend-select = ["C90", "UP"]
|
|
67
|
+
extend-ignore = ["UP015", "UP031"]
|
|
68
|
+
|
|
69
|
+
[tool.ruff.lint.mccabe]
|
|
70
|
+
max-complexity = 31
|
|
@@ -13,18 +13,12 @@ basepython = python3
|
|
|
13
13
|
[testenv:doc]
|
|
14
14
|
basepython = python3
|
|
15
15
|
deps = sphinx
|
|
16
|
-
|
|
16
|
+
allowlist_externals = make
|
|
17
17
|
commands=
|
|
18
18
|
make -C doc html
|
|
19
19
|
|
|
20
20
|
[testenv:pep8]
|
|
21
21
|
basepython = python3
|
|
22
|
-
deps =
|
|
22
|
+
deps = ruff
|
|
23
23
|
commands =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
[flake8]
|
|
27
|
-
# E501 line too long (88 > 79 characters)
|
|
28
|
-
# F812 list comprehension redefines 'loops' from line 56
|
|
29
|
-
# W503 line break before binary operator
|
|
30
|
-
ignore = E501,F812,W503
|
|
24
|
+
ruff check
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|