mew measures the cost of Python code using Google Benchmark. Write a benchmark function and run it from Python or the command line.
import mew
@mew.benchmark
def bench_sorted(state: mew.State) -> None:
data = list(range(1000, 0, -1))
for _ in state:
sorted(data)Save this as benchmarks/bench_sort.py, then run:
$ mew run --repetitions 10 -o baseline.jsonSetup before the loop is excluded from timing. mew chooses an iteration count and reports wall-clock and CPU time per iteration. After changing the code under test, measure again and compare against the baseline:
$ mew run --repetitions 10 -o candidate.json
$ mew compare baseline.json candidate.jsonYou can parametrize inputs, run benchmarks from a Python script, and save results as JSON or an appendable JSONL archive. Optional CPU and memory profilers help investigate changes.
$ pip install mew-bench
# Or, in a uv project:
$ uv add --dev mew-benchRequires Python 3.11 or later. A prebuilt wheel is installed where available. Other platforms compile the C++ extension from source.
- Quickstart
- Writing and measuring benchmarks
- Comparing and gating
- Using the Python API
- Recipes, including gating pull requests on regressions and tracking JAX through Git history
- API reference and CLI reference
The project license is Apache-2.0. Bundled third-party code also carries BSD-3-Clause and MIT licenses, see LICENSE and licenses/.