| 1 |
ASV Memray Benchmark Plugin documentation |
| 2 |
========================================= |
| 3 |
|
| 4 |
``asv_bench_memray`` is an externally defined ``memray`` benchmark plugin for |
| 5 |
:doc:`asv <asv:index>` using :doc:`asv_runner <asv_runner:index>`. |
| 6 |
|
| 7 |
.. toctree:: |
| 8 |
:maxdepth: 2 |
| 9 |
:caption: Contents: |
| 10 |
|
| 11 |
development |
| 12 |
apidocs/index |
| 13 |
|
| 14 |
Usage |
| 15 |
===== |
| 16 |
|
| 17 |
In your ``asv.conf.json`` add the following to the requirements matrix: |
| 18 |
|
| 19 |
.. code:: json |
| 20 |
|
| 21 |
"matrix": { |
| 22 |
"req": { |
| 23 |
"numpy": ["1.21"], |
| 24 |
"asv_plugin_memray": [""] |
| 25 |
}, |
| 26 |
}, |
| 27 |
|
| 28 |
This should be enough for an example like the following to run: |
| 29 |
|
| 30 |
.. code:: python |
| 31 |
|
| 32 |
import numpy as np |
| 33 |
|
| 34 |
class MyBenchmark: |
| 35 |
params = [10, int(2e4)] |
| 36 |
|
| 37 |
def ray_sum(self, n): |
| 38 |
self.data = np.random.rand(n) |
| 39 |
np.sum(self.data) |
| 40 |
|
| 41 |
Which should result in something roughly like: |
| 42 |
|
| 43 |
.. code:: sh |
| 44 |
|
| 45 |
ASV_RUNNER_PATH="../asv_runner" asv run --bench sum |
| 46 |
· Creating environments....... |
| 47 |
· Discovering benchmarks |
| 48 |
·· Uninstalling from virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21 |
| 49 |
·· Building 30a650cb <main> for virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21. |
| 50 |
·· Installing 30a650cb <main> into virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21 |
| 51 |
· Running 1 total benchmarks (1 commits * 1 environments * 1 benchmarks) |
| 52 |
[ 0.00%] · For project commit 30a650cb <main>: |
| 53 |
[ 0.00%] ·· Benchmarking virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21 |
| 54 |
[100.00%] ··· benchmarks.MyBenchmark.ray_sum ok |
| 55 |
[100.00%] ··· ======== ======= |
| 56 |
param1 |
| 57 |
-------- ------- |
| 58 |
10 1.72k |
| 59 |
20000 162k |
| 60 |
======== ======= |
| 61 |
|
| 62 |
ASV_RUNNER_PATH="../asv_runner" asv run --bench sum 8.72s user 3.04s system 99% cpu 11.877 total |
| 63 |
|
| 64 |
|
| 65 |
.. note:: |
| 66 |
|
| 67 |
The GitHub repository at `asv_samples |
| 68 |
<https://github.com/HaoZeke/asv_samples>`_ has a dedicated branch for |
| 69 |
testing ``asv_bench_memray``. |
| 70 |
|
| 71 |
License |
| 72 |
------- |
| 73 |
|
| 74 |
MIT. |
| 75 |
|
| 76 |
Indices and tables |
| 77 |
================== |
| 78 |
|
| 79 |
* :ref:`genindex` |
| 80 |
* :ref:`modindex` |
| 81 |
* :ref:`search` |