Airspeed Velocity (ASV)
Airspeed Velocity (asv) is a tool for benchmarking Python packages over their lifetime. It is primarily designed to benchmark a single project over its lifetime using a given suite of benchmarks. The results are displayed in an interactive web frontend that requires only a basic static webserver to host. The current version is 0.6.5, released in September 2025, and it maintains a relatively active release cadence with several updates per year.
Common errors
-
ImportError: No module named 'asv_runner'
cause This error occurs when the 'asv_runner' module is not installed or not found in the Python environment.fixEnsure that the 'asv' package is installed correctly by running 'pip install asv'. -
AttributeError: 'NoneType' object has no attribute 'group'
cause This error occurs when a regular expression search returns 'None', and the code attempts to call the 'group()' method on it.fixCheck if the regular expression search result is not 'None' before calling 'group()'. For example: 'match = re.search(pattern, string); if match: result = match.group()'. -
ModuleNotFoundError: No module named 'asv'
cause This error occurs when the 'asv' module is not installed or not found in the Python environment.fixInstall the 'asv' package using 'pip install asv'. -
asv: command not found
cause This error occurs when the 'asv' command-line tool is not installed or not found in the system's PATH.fixEnsure that the 'asv' package is installed and that the installation directory is included in the system's PATH. -
asv: error: unrecognized arguments
cause This error occurs when invalid or unrecognized arguments are passed to the 'asv' command.fixCheck the 'asv' command-line interface documentation for the correct usage and available arguments.
Warnings
- breaking Changing benchmark names, class names, or parameter names within your `benchmarks.py` files can invalidate historical data in ASV's reports. This makes it difficult to compare new results with past performance for the renamed benchmarks, essentially starting a new series.
- gotcha ASV is fundamentally a command-line tool (`asv quickstart`, `asv run`, `asv publish`, etc.). It's not typically imported as a Python library for direct programmatic use in application code. Attempting `import asv` to access benchmark running logic directly is not the intended usage model for most users.
- gotcha When configuring benchmark dependencies, `asv.conf.json` can specify `environment_matrix` settings (e.g., Python versions, specific package versions). If you also use `conda` or `mamba` with an `environment.yml` file, the explicit dependencies listed in `environment_matrix` within `asv.conf.json` will override those in `environment.yml`.
- gotcha ASV relies on Git or Mercurial for tracking project history and associating benchmark results with specific commits. While it can run benchmarks locally, its primary strength—historical performance tracking—requires an initialized Git or Mercurial repository.
- gotcha The acronym 'ASV' is also used in other contexts, such as Adaptive Servo-Ventilation (medical devices for sleep apnea) and ASV Inventions (motorcycle parts). When searching for or discussing the Python benchmarking tool, ensure the context is clear to avoid confusion.
Install
-
pip install asv
Imports
- asv
import asv; asv.run()
asv <command>
Quickstart
# 1. Initialize a new ASV benchmark suite # Run this in your project's root or a dedicated benchmark directory. asv quickstart # 2. Add a benchmark to benchmarks/benchmarks.py (example content below) # Create or edit 'benchmarks/benchmarks.py' with content like: # import numpy as np # # class TimeSuite: # def setup(self): # self.x = np.random.rand(1000, 1000) # # def time_sum_array(self): # np.sum(self.x) # # def time_dot_product(self): # np.dot(self.x, self.x) # # def teardown(self): # self.x = None # # class MemSuite: # def mem_full_array(self): # return np.random.rand(1000, 1000) # 3. Run the benchmarks asv run # 4. Publish the results to a web frontend asv publish # 5. Open the results in a web browser asv browse