Skip to content

Commit df91cac

Browse files
committed
set up benchmarks/profiling via asv
1 parent 7741fe9 commit df91cac

File tree

7 files changed

+472
-68
lines changed

7 files changed

+472
-68
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ MANIFEST
77
control/_version.py
88
__conda_*.txt
99
record.txt
10-
build.log
10+
*.log
1111
*.egg-info/
1212
.eggs/
1313
.coverage
@@ -23,3 +23,6 @@ Untitled*.ipynb
2323
# Files created by or for emacs (RMM, 29 Dec 2017)
2424
*~
2525
TAGS
26+
27+
# Files created by or for asv (airspeed velocity)
28+
.asv/

asv.conf.json

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
{
2+
// The version of the config file format. Do not change, unless
3+
// you know what you are doing.
4+
"version": 1,
5+
6+
// The name of the project being benchmarked
7+
"project": "python-control",
8+
9+
// The project's homepage
10+
"project_url": "http://python-control.org/",
11+
12+
// The URL or local path of the source code repository for the
13+
// project being benchmarked
14+
"repo": ".",
15+
16+
// The Python project's subdirectory in your repo. If missing or
17+
// the empty string, the project is assumed to be located at the root
18+
// of the repository.
19+
// "repo_subdir": ".",
20+
21+
// Customizable commands for building, installing, and
22+
// uninstalling the project. See asv.conf.json documentation.
23+
//
24+
// "install_command": ["in-dir={env_dir} python -mpip install {wheel_file}"],
25+
// "uninstall_command": ["return-code=any python -mpip uninstall -y {project}"],
26+
"build_command": [
27+
"python make_version.py",
28+
"python setup.py build",
29+
"PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}"
30+
],
31+
32+
// List of branches to benchmark. If not provided, defaults to "master"
33+
// (for git) or "default" (for mercurial).
34+
// "branches": ["master"], // for git
35+
// "branches": ["default"], // for mercurial
36+
37+
// The DVCS being used. If not set, it will be automatically
38+
// determined from "repo" by looking at the protocol in the URL
39+
// (if remote), or by looking for special directories, such as
40+
// ".git" (if local).
41+
// "dvcs": "git",
42+
43+
// The tool to use to create environments. May be "conda",
44+
// "virtualenv" or other value depending on the plugins in use.
45+
// If missing or the empty string, the tool will be automatically
46+
// determined by looking for tools on the PATH environment
47+
// variable.
48+
"environment_type": "conda",
49+
50+
// timeout in seconds for installing any dependencies in environment
51+
// defaults to 10 min
52+
//"install_timeout": 600,
53+
54+
// the base URL to show a commit for the project.
55+
"show_commit_url": "http://github.com/python-control/python-control/commit/",
56+
57+
// The Pythons you'd like to test against. If not provided, defaults
58+
// to the current version of Python used to run `asv`.
59+
// "pythons": ["2.7", "3.6"],
60+
61+
// The list of conda channel names to be searched for benchmark
62+
// dependency packages in the specified order
63+
// "conda_channels": ["conda-forge", "defaults"],
64+
65+
// The matrix of dependencies to test. Each key is the name of a
66+
// package (in PyPI) and the values are version numbers. An empty
67+
// list or empty string indicates to just test against the default
68+
// (latest) version. null indicates that the package is to not be
69+
// installed. If the package to be tested is only available from
70+
// PyPi, and the 'environment_type' is conda, then you can preface
71+
// the package name by 'pip+', and the package will be installed via
72+
// pip (with all the conda available packages installed first,
73+
// followed by the pip installed packages).
74+
//
75+
// "matrix": {
76+
// "numpy": ["1.6", "1.7"],
77+
// "six": ["", null], // test with and without six installed
78+
// "pip+emcee": [""], // emcee is only available for install with pip.
79+
// },
80+
81+
// Combinations of libraries/python versions can be excluded/included
82+
// from the set to test. Each entry is a dictionary containing additional
83+
// key-value pairs to include/exclude.
84+
//
85+
// An exclude entry excludes entries where all values match. The
86+
// values are regexps that should match the whole string.
87+
//
88+
// An include entry adds an environment. Only the packages listed
89+
// are installed. The 'python' key is required. The exclude rules
90+
// do not apply to includes.
91+
//
92+
// In addition to package names, the following keys are available:
93+
//
94+
// - python
95+
// Python version, as in the *pythons* variable above.
96+
// - environment_type
97+
// Environment type, as above.
98+
// - sys_platform
99+
// Platform, as in sys.platform. Possible values for the common
100+
// cases: 'linux2', 'win32', 'cygwin', 'darwin'.
101+
//
102+
// "exclude": [
103+
// {"python": "3.2", "sys_platform": "win32"}, // skip py3.2 on windows
104+
// {"environment_type": "conda", "six": null}, // don't run without six on conda
105+
// ],
106+
//
107+
// "include": [
108+
// // additional env for python2.7
109+
// {"python": "2.7", "numpy": "1.8"},
110+
// // additional env if run on windows+conda
111+
// {"platform": "win32", "environment_type": "conda", "python": "2.7", "libpython": ""},
112+
// ],
113+
114+
// The directory (relative to the current directory) that benchmarks are
115+
// stored in. If not provided, defaults to "benchmarks"
116+
// "benchmark_dir": "benchmarks",
117+
118+
// The directory (relative to the current directory) to cache the Python
119+
// environments in. If not provided, defaults to "env"
120+
"env_dir": ".asv/env",
121+
122+
// The directory (relative to the current directory) that raw benchmark
123+
// results are stored in. If not provided, defaults to "results".
124+
"results_dir": ".asv/results",
125+
126+
// The directory (relative to the current directory) that the html tree
127+
// should be written to. If not provided, defaults to "html".
128+
"html_dir": ".asv/html",
129+
130+
// The number of characters to retain in the commit hashes.
131+
// "hash_length": 8,
132+
133+
// `asv` will cache results of the recent builds in each
134+
// environment, making them faster to install next time. This is
135+
// the number of builds to keep, per environment.
136+
// "build_cache_size": 2,
137+
138+
// The commits after which the regression search in `asv publish`
139+
// should start looking for regressions. Dictionary whose keys are
140+
// regexps matching to benchmark names, and values corresponding to
141+
// the commit (exclusive) after which to start looking for
142+
// regressions. The default is to start from the first commit
143+
// with results. If the commit is `null`, regression detection is
144+
// skipped for the matching benchmark.
145+
//
146+
// "regressions_first_commits": {
147+
// "some_benchmark": "352cdf", // Consider regressions only after this commit
148+
// "another_benchmark": null, // Skip regression detection altogether
149+
// },
150+
151+
// The thresholds for relative change in results, after which `asv
152+
// publish` starts reporting regressions. Dictionary of the same
153+
// form as in ``regressions_first_commits``, with values
154+
// indicating the thresholds. If multiple entries match, the
155+
// maximum is taken. If no entry matches, the default is 5%.
156+
//
157+
// "regressions_thresholds": {
158+
// "some_benchmark": 0.01, // Threshold of 1%
159+
// "another_benchmark": 0.5, // Threshold of 50%
160+
// },
161+
}

benchmarks/README

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
This directory contains various scripts that can be used to measure the
2+
performance of the python-control package. The scripts are intended to be
3+
used with the airspeed velocity package (https://pypi.org/project/asv/) and
4+
are mainly intended for use by developers in identfying potential
5+
improvements to their code.
6+
7+
Running benchmarks
8+
------------------
9+
To run the benchmarks listed here against the current (uncommitted) code,
10+
you can use the following command from the root directory of the repository:
11+
12+
PYTHONPATH=`pwd` asv run --python=python
13+
14+
You can also run benchmarks against specific commits usuing
15+
16+
asv run <range>
17+
18+
where <range> is a range of commits to benchmark. To check against the HEAD
19+
of the branch that is currently checked out, use
20+
21+
asv run HEAD^!
22+
23+
Code profiling
24+
--------------
25+
You can also use the benchmarks to profile code and look for bottlenecks.
26+
To profile a given test against the current (uncommitted) code use
27+
28+
PYTHONPATH=`pwd` asv profile --python=python <file>.<test>
29+
30+
where <file> is the name of one of the files in the benchmark/ subdirectory
31+
and <test> is the name of a test function in that file.
32+
33+
If you have the `snakeviz` profiling visualization package installed, the
34+
following command will profile a test against the HEAD of the current branch
35+
and open a graphical representation of the profiled code:
36+
37+
asv profile --gui snakeviz <file>.<test> HEAD
38+
39+
RMM, 27 Feb 2021

benchmarks/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)