simplebench.reporters.graph.scatterplot package🔗

ScatterPlot graph.scatterplot module in the reporters package.

Purpose is to provide a scatter plot reporter for the simplebench.reporters package.

This package provides functionality for generating scatter plot graphs using Matplotlib as the underlying graphing library.

Public API🔗

class simplebench.reporters.graph.scatterplot.ScatterPlotConfig(
*,
name: str | None = None,
description: str | None = None,
sections: Iterable[Section] | None = None,
targets: Iterable[Target] | None = None,
default_targets: Iterable[Target] | None = None,
formats: Iterable[Format] | None = None,
choices: ChoicesConf | None = None,
file_suffix: str | None = None,
file_unique: bool | None = None,
file_append: bool | None = None,
subdir: str | None = None,
)[source]🔗

Bases: ReporterConfig

Configuration for a ScatterPlotReporter.

This class inherits from ReporterConfig and provides a type-safe, discoverable interface for overriding the default settings of a ScatterPlotReporter.

Initialize the ScatterPlotReporter configuration.

Accepts keyword arguments to override any of the default configurations. All arguments are optional. If not provided, the default value for ScatterPlotReporter will be used.

class simplebench.reporters.graph.scatterplot.ScatterPlotOptions(
width: int | None = None,
height: int | None = None,
dpi: int | None = None,
y_starts_at_zero: bool | None = None,
x_labels_rotation: float | None = None,
style: Style | None = None,
theme: Theme | None = None,
image_type: ImageType | None = None,
)[source]🔗

Bases: MatPlotLibOptions

Scatter Plot options.

Defaults are inherited from MatPlotLibOptions:

  • width: int = 1500

  • height: int = 750

  • dpi: int = 150

  • y_starts_at_zero: bool = True

  • x_labels_rotation: float = 45.0

  • style: Style = Style.DARK_BACKGROUND

  • theme: Theme = Theme.Default

  • image_type: ImageType = ImageType.SVG

Create a MatPlotLibOptions instance.

To ensure accuracy in graph rendering, the default width, height, and DPI should be set with the width and height being exact multiples of the DPI. This is because the underlying rendering engine uses DPI to determine the pixel dimensions of the output graph from the specified width and height in inches.

If the width and height are not exact multiples of the DPI, it may lead to unexpected scaling or distortion of the graph when rendered, as the rendering engine may round the pixel dimensions to the nearest whole number.

The default values provided here are chosen to balance quality and performance for most common use cases. However, users can customize these values based on their specific requirements for graph resolution and size.

The use of None for (or, equivalently the omission of) any argument indicates that the default value defined in the next lower precedence level should be used.

Parameters:
  • width (int | None) – The width in pixels of a MatPlotLib output when rendered. It should be an exact multiple of the dpi and can only be between 500 and 4000 pixels. If None, the default MatPlotLibOptions default width will be used.

  • height (int | None) – The height in pixels of a MatPlotLib output when rendered. It should be an exact multiple of the dpi and can only be between 500 and 4000 pixels. If None, the default MatPlotLibOptions default height will be used.

  • dpi (int | None) – The default DPI (dots per inch) for a MatPlotLib output. It must be between 50 and 400.

  • y_starts_at_zero (bool | None) – Whether the Y-axis should start at zero.

  • x_labels_rotation (float | None) – The rotation angle in degrees for X-axis labels.

  • style (Style | None) – The default style for the MatPlotLib graphs.

  • theme (Theme | None) – The theme to use for the MatPlotLib graphs.

  • image_type (ImageType | None) – The output format for the graph files.

Raises:
class simplebench.reporters.graph.scatterplot.ScatterPlotReporter(
config: ScatterPlotConfig | None = None,
)[source]🔗

Bases: MatPlotLibReporter

Class for outputting benchmark results as scatter plot graphs.

This reporter generates scatter plot visualizations for various result sections, saving them to the filesystem or passing them to a callback function. It provides a visual way to compare the performance of different benchmark variations.

Defined command-line flags:

  • --scatter-plot: {filesystem, callback} (default=filesystem)

  • --scatter-plot.ops: ...

  • --scatter-plot.timings: ...

  • --scatter-plot.memory: ...

Example usage:

program.py --scatter-plot               # Outputs graphs to the filesystem.
program.py --scatter-plot.ops filesystem  # Outputs only ops graphs to the filesystem.

Initialize the ScatterPlotReporter.

Note

The exception documentation below refers to validation of subclass configuration class variables _OPTIONS_TYPE and _OPTIONS_KWARGS. These must be correctly defined in any subclass of ScatterPlotReporter to ensure proper functionality.

Parameters:

config (ScatterPlotConfig | None) – An optional configuration object to override default reporter settings. If not provided, default settings will be used.

Raises:
render(
*,
case: Case,
section: Section,
options: ReporterOptions,
) bytes[source]🔗

Render the scatter plot graph and return it as bytes.

Parameters:
  • case – The Case instance representing the benchmarked code.

  • section – The section of the results to plot.

  • options – The options for rendering the scatter plot.

Returns:

The rendered graph as bytes. The format is determined by the options. The defaults are defined in ScatterPlotOptions.

Raises:

Subpackages🔗