simplebench.stats.memory_usage moduleπŸ”—

Containers for benchmark statistics

class simplebench.stats.memory_usage.MemoryUsage(
*,
iterations: Sequence[Iteration] | None = None,
unit: str = 'bytes',
scale: float = 1.0,
rounds: int = 1,
data: Sequence[int | float] | None = None,
)[source]πŸ”—

Bases: Stats

Container for the memory usage statistics of a benchmark.

Variables:
  • unit (str) – The unit of measurement for the memory usage (e.g., β€œMB”).

  • scale (float) – The scale factor for the memory usage (e.g., β€œ1e6” for megabytes).

  • rounds (int) – The number of data points in the benchmark.

  • data (tuple[float | int, ...]) – Tuple of memory usage data points.

  • mean (float) – The mean memory usage.

  • median (float) – The median memory usage.

  • minimum (float) – The minimum memory usage.

  • maximum (float) – The maximum memory usage.

  • standard_deviation (float) – The standard deviation of the memory usage.

  • relative_standard_deviation (float) – The relative standard deviation of the memory usage.

  • percentiles (dict[int, float]) – Percentiles of memory usage.

Construct MemoryUsage stats from sequence of Iteration or raw memory data.

At least one of iterations or data must be provided.

If provided, iterations must be a sequence of Iteration objects and memory data will be extracted from each memory attribute. If data is also provided, the memory data extracted from the iterations will be appended to the provided data.

Parameters:
  • iterations – Optional list of Iteration objects to extract memory data from.

  • unit – Optional unit of measurement for the memory usage (e.g., β€œMB”). Defaults to β€˜bytes’.

  • scale – Optional scale factor for the memory usage (e.g., β€œ1e6” for megabytes). Defaults to 1.0.

  • rounds – The number of data points in the benchmark. Defaults to 1.

  • data – Optional list of memory usage data points. If not provided, memory data will be extracted from the iterations if available.

Raises:
class simplebench.stats.memory_usage.MemoryUsageSummary(
*,
unit: str,
scale: float,
rounds: int,
mean: float,
median: float,
minimum: float,
maximum: float,
standard_deviation: float,
relative_standard_deviation: float,
percentiles: tuple[float, ...],
)[source]πŸ”—

Bases: StatsSummary

Container for summary statistics of a MemoryUsage benchmark.

This class is exclusive of raw data points.

Variables:
  • unit (str) – The unit of measurement for the benchmark (e.g., β€œops/s”).

  • scale (float) – The scale factor for the interval (e.g. 1 for seconds).

  • rounds (int) – The number of data points in the benchmark.

  • data (tuple[int | float, ...]) – Always an empty tuple as a StatsSummary object does not contain raw data points.

  • mean (float) – The mean operations per time interval.

  • median (float) – The median operations per time interval.

  • minimum (float) – The minimum operations per time interval.

  • maximum (float) – The maximum operations per time interval.

  • standard_deviation (float) – The standard deviation of operations per time interval.

  • relative_standard_deviation (float) – The relative standard deviation of ops per time interval.

  • percentiles (tuple[float, ...]) – Percentiles of operations per time interval.

Initialize the StatsSummary object.

Parameters:
  • unit (str) – The unit of measurement for the data (e.g., β€œops/s”).

  • scale (float) – The scale factor the data (e.g. 1.0 for seconds).

  • rounds (int) – The number of rounds each data point represents.

  • mean (float) – The mean data point.

  • median (float) – The median data point.

  • minimum (float) – The minimum data point.

  • maximum (float) – The maximum data point.

  • standard_deviation (float) – The standard deviation of data.

  • relative_standard_deviation (float) – The relative standard deviation of data.

  • percentiles (tuple[float, ...]) – Percentiles of data.

Raises: