Name | perfplot JSON |
Version |
0.11.1
JSON |
| download |
home_page | |
Summary | Performance plots for Python code snippets |
upload_time | 2023-01-27 21:25:18 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | |
keywords |
performance
profile
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<p align="center">
<a href="https://github.com/nschloe/perfplot"><img alt="perfplot" src="https://nschloe.github.io/perfplot/logo-perfplot.svg" width="60%"></a>
</p>
[](https://pypi.org/project/perfplot)
[](https://pypi.org/pypi/perfplot/)
[](https://github.com/nschloe/perfplot)
[](https://pepy.tech/project/perfplot)
<!--[](https://pypistats.org/packages/perfplot)-->
[](https://discord.gg/hnTJ5MRX2Y)
perfplot extends Python's
[timeit](https://docs.python.org/3/library/timeit.html) by testing snippets
with input parameters (e.g., the size of an array) and plotting the results.
For example, to compare different NumPy array concatenation methods, the script
```python
import numpy as np
import perfplot
perfplot.show(
setup=lambda n: np.random.rand(n), # or setup=np.random.rand
kernels=[
lambda a: np.c_[a, a],
lambda a: np.stack([a, a]).T,
lambda a: np.vstack([a, a]).T,
lambda a: np.column_stack([a, a]),
lambda a: np.concatenate([a[:, None], a[:, None]], axis=1),
],
labels=["c_", "stack", "vstack", "column_stack", "concat"],
n_range=[2**k for k in range(25)],
xlabel="len(a)",
# More optional arguments with their default values:
# xscale="auto", # "log", "linear", or "auto"
# yscale="auto",
# equality_check=np.allclose, # set to None to disable "correctness" assertion
# show_progress=True,
# target_time_per_measurement=1.0,
# max_time=None, # maximum time per measurement
# time_unit="s", # set to one of ("auto", "s", "ms", "us", or "ns") to force plot units
# relative_to=1, # plot the timings relative to one of the measurements
# flops=lambda n: 3*n, # FLOPS plots
)
```
produces
|  |  |
| -------------------------------------------------- | ---------------------------------------------------- |
Clearly, `stack` and `vstack` are the best options for large arrays.
(By default, perfplot asserts the equality of the output of all snippets, too.)
If your plot takes a while to generate, you can also use
<!--pytest.mark.skip-->
```python
perfplot.live(
# ...
)
```
<img alt="live" src="https://nschloe.github.io/perfplot/live.gif" width="40%">
with the same arguments as above. It will plot the updates live.
Benchmarking and plotting can be separated. This allows multiple plots of the same data,
for example:
<!--pytest.mark.skip-->
```python
out = perfplot.bench(
# same arguments as above (except the plot-related ones, like time_unit or log*)
)
out.show()
out.save("perf.png", transparent=True, bbox_inches="tight")
```
Other examples:
- [Making a flat list out of list of lists in Python](https://stackoverflow.com/a/45323085/353337)
- [Most efficient way to map function over numpy array](https://stackoverflow.com/a/46470401/353337)
- [numpy: most efficient frequency counts for unique values in an array](https://stackoverflow.com/a/43096495/353337)
- [Most efficient way to reverse a numpy array](https://stackoverflow.com/a/44921013/353337)
- [How to add an extra column to an numpy array](https://stackoverflow.com/a/40218298/353337)
- [Initializing numpy matrix to something other than zero or one](https://stackoverflow.com/a/45006691/353337)
### Installation
perfplot is [available from the Python Package
Index](https://pypi.org/project/perfplot/), so simply do
```
pip install perfplot
```
to install.
### Testing
To run the perfplot unit tests, check out this repository and type
```
tox
```
Raw data
{
"_id": null,
"home_page": "",
"name": "perfplot",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "performance,profile",
"author": "",
"author_email": "Nico Schl\u00f6mer <nico.schloemer@gmail.com>",
"download_url": "",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://github.com/nschloe/perfplot\"><img alt=\"perfplot\" src=\"https://nschloe.github.io/perfplot/logo-perfplot.svg\" width=\"60%\"></a>\n</p>\n\n[](https://pypi.org/project/perfplot)\n[](https://pypi.org/pypi/perfplot/)\n[](https://github.com/nschloe/perfplot)\n[](https://pepy.tech/project/perfplot)\n\n<!--[](https://pypistats.org/packages/perfplot)-->\n\n[](https://discord.gg/hnTJ5MRX2Y)\n\nperfplot extends Python's\n[timeit](https://docs.python.org/3/library/timeit.html) by testing snippets\nwith input parameters (e.g., the size of an array) and plotting the results.\n\nFor example, to compare different NumPy array concatenation methods, the script\n\n```python\nimport numpy as np\nimport perfplot\n\nperfplot.show(\n setup=lambda n: np.random.rand(n), # or setup=np.random.rand\n kernels=[\n lambda a: np.c_[a, a],\n lambda a: np.stack([a, a]).T,\n lambda a: np.vstack([a, a]).T,\n lambda a: np.column_stack([a, a]),\n lambda a: np.concatenate([a[:, None], a[:, None]], axis=1),\n ],\n labels=[\"c_\", \"stack\", \"vstack\", \"column_stack\", \"concat\"],\n n_range=[2**k for k in range(25)],\n xlabel=\"len(a)\",\n # More optional arguments with their default values:\n # xscale=\"auto\", # \"log\", \"linear\", or \"auto\"\n # yscale=\"auto\",\n # equality_check=np.allclose, # set to None to disable \"correctness\" assertion\n # show_progress=True,\n # target_time_per_measurement=1.0,\n # max_time=None, # maximum time per measurement\n # time_unit=\"s\", # set to one of (\"auto\", \"s\", \"ms\", \"us\", or \"ns\") to force plot units\n # relative_to=1, # plot the timings relative to one of the measurements\n # flops=lambda n: 3*n, # FLOPS plots\n)\n```\n\nproduces\n\n|  |  |\n| -------------------------------------------------- | ---------------------------------------------------- |\n\nClearly, `stack` and `vstack` are the best options for large arrays.\n\n(By default, perfplot asserts the equality of the output of all snippets, too.)\n\nIf your plot takes a while to generate, you can also use\n\n<!--pytest.mark.skip-->\n\n```python\nperfplot.live(\n # ...\n)\n```\n\n<img alt=\"live\" src=\"https://nschloe.github.io/perfplot/live.gif\" width=\"40%\">\n\nwith the same arguments as above. It will plot the updates live.\n\nBenchmarking and plotting can be separated. This allows multiple plots of the same data,\nfor example:\n\n<!--pytest.mark.skip-->\n\n```python\nout = perfplot.bench(\n # same arguments as above (except the plot-related ones, like time_unit or log*)\n)\nout.show()\nout.save(\"perf.png\", transparent=True, bbox_inches=\"tight\")\n```\n\nOther examples:\n\n- [Making a flat list out of list of lists in Python](https://stackoverflow.com/a/45323085/353337)\n- [Most efficient way to map function over numpy array](https://stackoverflow.com/a/46470401/353337)\n- [numpy: most efficient frequency counts for unique values in an array](https://stackoverflow.com/a/43096495/353337)\n- [Most efficient way to reverse a numpy array](https://stackoverflow.com/a/44921013/353337)\n- [How to add an extra column to an numpy array](https://stackoverflow.com/a/40218298/353337)\n- [Initializing numpy matrix to something other than zero or one](https://stackoverflow.com/a/45006691/353337)\n\n### Installation\n\nperfplot is [available from the Python Package\nIndex](https://pypi.org/project/perfplot/), so simply do\n\n```\npip install perfplot\n```\n\nto install.\n\n### Testing\n\nTo run the perfplot unit tests, check out this repository and type\n\n```\ntox\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "Performance plots for Python code snippets",
"version": "0.11.1",
"split_keywords": [
"performance",
"profile"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "80a844a0411bd63165daba48496ec5be90b142dee6af367cc39371882070ada5",
"md5": "729795d492f87821df27727a2bc36c60",
"sha256": "a2f97f71521fb51d5e1aa8f73ffc33a19e986b305cc763193494859c0dc52471"
},
"downloads": -1,
"filename": "perfplot-0.11.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "729795d492f87821df27727a2bc36c60",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 21280,
"upload_time": "2023-01-27T21:25:18",
"upload_time_iso_8601": "2023-01-27T21:25:18.383652Z",
"url": "https://files.pythonhosted.org/packages/80/a8/44a0411bd63165daba48496ec5be90b142dee6af367cc39371882070ada5/perfplot-0.11.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-27 21:25:18",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "perfplot"
}