The Python perf module is a toolkit to write, run and analyze benchmarks.
- Simple API to run reliable benchmarks
- Automatically calibrate a benchmark for a time budget.
- Spawn multiple worker processes.
- Compute the mean and standard deviation.
- Detect if a benchmark result seems unstable.
- perf stats command to analyze the distribution of benchmark
results (min/max, mean, median, percentiles, etc.).
- perf compare_to command tests if a difference if
significant. It supports comparison between multiple benchmark suites (made
of multiple benchmarks)
- perf timeit command line tool for quick but reliable
- perf system tune command to tune your system to run stable benchmarks.
- Automatically collect metadata on the computer and the benchmark:
use the perf metadata command to display them, or the
perf collect_metadata command to manually collect them.
- --track-memory and --tracemalloc options to track
the memory usage of a benchmark.
- JSON format to store benchmark results.
- Support multiple units: seconds, bytes and integer.
Command to install perf on Python 3:
python3 -m pip install perf
perf supports Python 2.7 and Python 3. It is distributed under the MIT license.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.