State and Runs

class mew.State(*args, **kwargs)[source]

Bases: Protocol

Structural state passed into benchmark targets.

Matched by the C++ _core.State and the _ProfileState used for out-of-loop profile passes. Covers iteration, timing control, counters, labels, and range/thread accessors.

range_size: int
threads: int
thread_index: int
name: str
skipped: bool
error_occurred: bool
property iterations: int
property max_iterations: int
keep_running_batch(n)[source]
Return type:

bool

Parameters:

n (int)

batches(n)[source]
Return type:

Iterator[int]

Parameters:

n (int)

pause()[source]
Return type:

AbstractContextManager[None]

set_counter(name, value)[source]
Return type:

None

Parameters:
set_label(label)[source]
Return type:

None

Parameters:

label (str)

set_items_processed(n)[source]
Return type:

None

Parameters:

n (int)

set_bytes_processed(n)[source]
Return type:

None

Parameters:

n (int)

set_iteration_time(seconds)[source]
Return type:

None

Parameters:

seconds (float)

skip_with_error(msg)[source]
Return type:

None

Parameters:

msg (str)

skip_with_message(msg)[source]
Return type:

None

Parameters:

msg (str)

range(pos=0)[source]
Return type:

int

Parameters:

pos (int)

class mew.BenchmarkFn(*args, **kwargs)[source]

Bases: Protocol

A callable benchmark target.

Bound to Google Benchmark via the @benchmark / @parametrize / @product decorators. The first positional argument is a State; parametrized families bind additional kwargs at variant construction time.

class mew.BenchmarkHandle

Bases: object

Handle to a registered Google Benchmark. Methods return the same handle so options can be chained. Invalidated by the next clear_registered_benchmarks() call or interpreter shutdown; using a stale handle is undefined behaviour.

arg(self, value: int) mew._core.BenchmarkHandle
arg_name(self, name: str) mew._core.BenchmarkHandle
dense_range(self, start: int, limit: int, step: int = 1) mew._core.BenchmarkHandle
display_aggregates_only(self, value: bool = True) mew._core.BenchmarkHandle
iterations(self, n: int) mew._core.BenchmarkHandle
measure_process_cpu_time(self) mew._core.BenchmarkHandle
min_time(self, seconds: float) mew._core.BenchmarkHandle
min_warmup_time(self, seconds: float) mew._core.BenchmarkHandle
property name

(self) -> str

repetitions(self, n: int) mew._core.BenchmarkHandle
report_aggregates_only(self, value: bool = True) mew._core.BenchmarkHandle
unit(self, unit: Literal['ns', 'us', 'ms', 's']) BenchmarkHandle
unit(self, unit: mew._core.TimeUnit) mew._core.BenchmarkHandle
use_manual_time(self) mew._core.BenchmarkHandle
use_real_time(self) mew._core.BenchmarkHandle

Run records

Results delivered to reporters are :class:Run objects (or

class:

~mew._profile.EnrichedRun when a profiling pass has run):

class mew.Run

Bases: object

A single benchmark run report. Times are in seconds (accumulated across iterations); use adjusted_real_time() for per-iteration averages. Carries a __dict__ (dynamic_attr) so out-of-loop profile passes can attach .memory / .cpu to a row in place.

adjusted_cpu_time(self) float
adjusted_real_time(self) float
property aggregate_name

(self) -> str

benchmark_name(self) str
property complexity_n

(self) -> int

property counters

(self) -> dict

property cpu_accumulated_time

(self) -> float

property family_index

(self) -> int

property iterations

(self) -> int

property per_family_instance_index

(self) -> int

property real_accumulated_time

(self) -> float

property repetition_index

(self) -> int

property repetitions

(self) -> int

property report_label

(self) -> str

property run_name

(self) -> mew._core.BenchmarkName

property run_type

(self) -> mew._core.RunType

property skip_message

(self) -> str

property skipped

(self) -> bool

property threads

(self) -> int

property time_unit

(self) -> mew._core.TimeUnit

class mew.RunType(*values)

Bases: Enum

Distinguishes per-repetition runs from aggregate (mean / median / stddev) rows.

iteration = 0
aggregate = 1
class mew.TimeUnit(*values)

Bases: Enum

Time unit used for reported per-iteration durations.

ns = 0
us = 1
ms = 2
s = 3