Skip to main content

A memray benchmark plugin for asv

Project description

asv_bench_memray

This a proof-of-concept externally defined memray benchmark plugin for asv.

Usage

In your asv.conf.json add the following to the requirements matrix:

"matrix": {
    "req": {
        "numpy": ["1.21"],
        "asv_plugin_memray": [""]
    },
},

This should be enough for an example like the following to run:

import numpy as np

class MyBenchmark:
    params = [10, int(2e4)]

    def ray_sum(self, n):
        self.data = np.random.rand(n)
        np.sum(self.data)

Which should result in something roughly like:

ASV_RUNNER_PATH="../asv_runner" asv run --bench sum
· Creating environments.......
· Discovering benchmarks
·· Uninstalling from virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21
·· Building 30a650cb <main> for virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21.
·· Installing 30a650cb <main> into virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21
· Running 1 total benchmarks (1 commits * 1 environments * 1 benchmarks)
[ 0.00%] · For project commit 30a650cb <main>:
[ 0.00%] ·· Benchmarking virtualenv-py3.9-asv_bench_memray.._asv_bench_memray-numpy1.21
[100.00%] ··· benchmarks.MyBenchmark.ray_sum                                                ok
[100.00%] ··· ======== =======
               param1         
              -------- -------
                 10     1.72k 
               20000     162k 
              ======== =======

ASV_RUNNER_PATH="../asv_runner" asv run --bench sum  8.72s user 3.04s system 99% cpu 11.877 total

Development

During development, one needs to pass a relative path:

"matrix": {
    "req": {
        "asv_bench_memray": ["../asv_bench_memray"]
    },
},

Also it may be necessary to cleanup older environments and explicitly point to an instance of asv_runner:

rm -rf .asv && ASV_RUNNER_PATH="../asv_runner" asv run --bench sum

Personally I keep benchmarks for testing at an experiments repo, but any local test will do.

Conventions

Like all externally defined benchmark plugins for asv, this has a strict hierarchy.

  • The package name begins with asv_bench
  • Benchmarks are defined in a benchmarks folder under the package module
  • Each exported new benchmark type has the export_as_benchmark = [NAMEBenchmark] attribute

For more conventions follow the documention of asv_runner.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asv_bench_memray-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

asv_bench_memray-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file asv_bench_memray-0.1.1.tar.gz.

File metadata

  • Download URL: asv_bench_memray-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for asv_bench_memray-0.1.1.tar.gz
Algorithm Hash digest
SHA256 654a5bb989e15d2a6b46d85349b492f83605ae1e89d95f76f8f5943d5723cb8f
MD5 c3c516f688efaecfc9b1f6c0c53608b9
BLAKE2b-256 469474d7eafa946bad1773bf213b403b7d0a16d3eb0dfe55cfc86f6d5633fb21

See more details on using hashes here.

File details

Details for the file asv_bench_memray-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for asv_bench_memray-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 425f76d91d0f613a1e4304437aa20ab43bb0aa53836dfa877cd9c0669014ed60
MD5 d742d9960917961c5a163f086dd7cff9
BLAKE2b-256 195706096290ab1a2ac30c7ff51a0ba5aa3af00eacf8fe890ab3a18bff6b3e56

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page