Sept. 8, 2024
Benchmarks with Air Speed Velocity
More on:
Go back
Air Speed Velocity (asv) is a tool to benchmark a project's performance. These notes could be used as a complement to its documentation.
Many open source projects use
The benchmarks that
Before installing
There is an example in the documentation. One needs to edit the file
You can use the benchmarks already written on
The first time you run
In order to run
So, the project needs to have a structure and a file with its configuration. You also need to install a package called
Remove the "//" (comment) on
In order to To run only one benchmark, you need this command:
Many open source projects use
asv
, and they run the benchmarks on separate servers. The results are published on yet another server.
The benchmarks that
asv
runs are short python scripts that call the project's functions or methods. It needs a JSON
configuration file for it to work. Then the result of the tests are stored in JSON
format files as well, and they can grow quite large. Then asv
displays the results in a web frontend. So, it normally needs a host.
Before installing
asv
, an environment must be created and activated. The library has a command asv quickstart
that creates a “skeleton” (some files) that you need to edit in order to benchmark your project. When you run this command, it first asks you about the configuration that you want.
There is an example in the documentation. One needs to edit the file
asv.conf.json
that was created with asv quickstart
to run it.
You can use the benchmarks already written on
benchmarks.py
, but make sure that asv.conf.json
has
"repo": “https://github.com/airspeed-velocity/asv.git", also
“branches”: [“main”], and that “environment_type" matches your environment.
The first time you run
asv
, it will ask you for details about your machine. Follow the basic commands on the documentation to run and view the results.
In order to run
asv
with a real project, it needs to build it. So the project needs to be a distribution package (or “installable”). I used setuptools.
So, the project needs to have a structure and a file with its configuration. You also need to install a package called
build
to your environment. The configuration can be handled with just the pyproject.toml
file.
Remove the "//" (comment) on
asv.conf.json
to use pyproject.toml
and not setup.py
.
In order to To run only one benchmark, you need this command:
asv run --bench name_of_your_benchmark