Skip to content
nicholasjngPublic

About

A microbenchmarking CLI for Python.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

mew

Documentation Status CI

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.json

Setup 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.json

You 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.

Installation

$ pip install mew-bench
# Or, in a uv project:
$ uv add --dev mew-bench

Requires Python 3.11 or later. A prebuilt wheel is installed where available. Other platforms compile the C++ extension from source.

Documentation

License

The project license is Apache-2.0. Bundled third-party code also carries BSD-3-Clause and MIT licenses, see LICENSE and licenses/.

About

A microbenchmarking CLI for Python.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages