simplebench.results moduleπ
Container for the results of a single benchmark test.
- class simplebench.results.Results(
- *,
- group: str,
- title: str,
- description: str,
- n: int | float,
- rounds: int,
- total_elapsed: float,
- iterations: Sequence[Iteration],
- variation_cols: dict[str, str] | None = None,
- variation_marks: dict[str, Any] | None = None,
- interval_unit: str = 'ns',
- interval_scale: float = 1e-09,
- ops_per_interval_unit: str = 'ns',
- ops_per_interval_scale: float = 1e-09,
- memory_unit: str = 'bytes',
- memory_scale: float = 1.0,
- ops_per_second: OperationsPerInterval | None = None,
- per_round_timings: OperationTimings | None = None,
- memory: MemoryUsage | None = None,
- peak_memory: PeakMemoryUsage | None = None,
- extra_info: dict[str, Any] | None = None,
Bases:
objectContainer for the results of a single benchmark test.
The Results class holds all relevant information about a benchmark testβs execution and its outcomes. It is immutable after creation to ensure data integrity.
- Variables:
group (str) β The reporting group to which the benchmark case belongs. (read only)
title (str) β The name of the benchmark case. (read only)
description (str) β A brief description of the benchmark case. (read only)
n (int | float) β The n weighting the benchmark assigned to the iteration for purposes of Big O analysis. (read only)
rounds (int) β The number of rounds in the benchmark case. (read only)
variation_marks (MappingProxyType[str, Any]) β A dictionary of variation marks used to identify the benchmark variation. (read only)
variation_cols (MappingProxyType[str, str]) β The columns to use for labelling kwarg variations in the benchmark. (read only)
interval_unit (str) β The unit of measurement for the interval (e.g. βnsβ). (read only)
interval_scale (float) β The scale factor for the interval (e.g. 1e-9 for nanoseconds). (read only)
ops_per_interval_unit (str) β The unit of measurement for operations per interval (e.g. βops/sβ). (read only)
ops_per_interval_scale (float) β The scale factor for operations per interval (e.g. 1.0 for ops/s). (read only)
memory_unit (str) β The unit of measurement for memory usage (e.g. βbytesβ). (read only)
memory_scale (float) β The scale factor for memory usage (e.g. 1.0 for bytes). (read only)
iterations (tuple[Iteration, ...]) β A tuple of Iteration objects representing each iteration of the benchmark. (read only)
ops_per_second (OperationsPerInterval) β Statistics for operations per interval. (read only)
per_round_timings (OperationTimings) β Statistics for per-round timings. (read only)
memory (MemoryUsage) β Statistics for memory usage. (read only)
peak_memory (PeakMemoryUsage) β Statistics for peak memory usage. (read only)
total_elapsed (float) β The total elapsed time for the benchmark. (read only)
extra_info (MappingProxyType[str, Any]) β Additional information about the benchmark run. This is a read-only property that returns a mapping proxy to prevent external mutation. (read only)
Initialize a Results object.
- Parameters:
group (str) β The reporting group to which the benchmark case belongs.
title (str) β The name of the benchmark case.
description (str) β A brief description of the benchmark case.
n (int | float) β The n weighting assigned to the iteration for purposes of Big O analysis.
rounds (int) β The number of rounds in the benchmark case.
total_elapsed (float) β The total elapsed time for the benchmark.
iterations (list[Iteration]) β The list of Iteration objects representing each iteration of the benchmark.
variation_cols (dict[str, str], optional) β The columns to use for labelling kwarg variations in the benchmark. Defaults to None, which results in an empty dictionary.
variation_marks (dict[str, Any], optional) β A dictionary of variation marks used to identify the benchmark variation. Defaults to None, which results in an empty dictionary.
interval_unit (str, optional) β The unit of measurement for the interval (e.g. βnsβ). Defaults to βnsβ.
interval_scale (float, optional) β The scale factor for the interval (e.g. 1e-9 for nanoseconds). Defaults to 1e-9.
ops_per_interval_unit (str, optional) β The unit of measurement for operations per interval (e.g. βops/sβ). Defaults to βops/sβ.
ops_per_interval_scale (float, optional) β The scale factor for operations per interval (e.g. 1.0 for ops/s). Defaults to 1.0.
memory_unit (str, optional) β The unit of measurement for memory usage (e.g. βbytesβ). Defaults to βbytesβ.
memory_scale (float, optional) β The scale factor for memory usage (e.g. 1.0 for bytes). Defaults to 1.0.
ops_per_second (Optional[OperationsPerInterval], optional) β The operations per second for the benchmark. Defaults to a new OperationsPerInterval object initialized from the benchmarkβs iterations.
per_round_timings (Optional[OperationTimings], optional) β The per-round timings for the benchmark. Defaults to a new OperationTimings object initialized from the benchmarkβs iterations.
memory (Optional[MemoryUsage], optional) β The memory usage for the benchmark. Defaults to a new MemoryUsage object initialized from the benchmarkβs iterations.
peak_memory (Optional[PeakMemoryUsage], optional) β The peak memory usage for the benchmark. Defaults to a new PeakMemoryUsage object initialized from the benchmarkβs iterations.
extra_info (Optional[dict[str, Any]], optional) β Any extra information to include in the benchmark results. Defaults to {}.
- Raises:
SimpleBenchTypeError β If any of the arguments are of incorrect type.
SimpleBenchValueError β If any of the arguments have invalid values.
- as_dict(
- full_data: bool = False,
Returns the benchmark results and statistics as a JSON-serializable dictionary.
- property iterations: tuple[Iteration, ...]π
The tuple of Iteration objects representing each iteration of the benchmark.
- property memory: MemoryUsageπ
Statistics for memory usage.
- property ops_per_interval_scale: floatπ
The scale factor for operations per interval (e.g. 1.0 for ops/s).
- property ops_per_interval_unit: strπ
The unit of measurement for operations per interval (e.g. βops/sβ).
- property ops_per_second: OperationsPerIntervalπ
Statistics for operations per interval.
- property peak_memory: PeakMemoryUsageπ
Statistics for peak memory usage.
- property per_round_timings: OperationTimingsπ
Statistics for per-round timings.
- results_section(
- section: Section,
Returns the requested section of the benchmark results.