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🔗
ScatterPlotConfig: Configuration class for the ScatterPlot reporter.ScatterPlotOptions: Options class for the ScatterPlot reporter.ScatterPlotReporter: The ScatterPlot reporter class.
- 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,
Bases:
ReporterConfigConfiguration for a ScatterPlotReporter.
This class inherits from
ReporterConfigand provides a type-safe, discoverable interface for overriding the default settings of aScatterPlotReporter.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,
Bases:
MatPlotLibOptionsScatter Plot options.
Defaults are inherited from
MatPlotLibOptions:width: int = 1500height: int = 750dpi: int = 150y_starts_at_zero: bool = Truex_labels_rotation: float = 45.0style: Style = Style.DARK_BACKGROUNDtheme: Theme = Theme.Defaultimage_type: ImageType = ImageType.SVG
Create a
MatPlotLibOptionsinstance.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
Nonefor (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 defaultMatPlotLibOptionsdefault 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 defaultMatPlotLibOptionsdefault 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:
SimpleBenchTypeError – If any of the arguments are of incorrect type.
SimpleBenchValueError – If any of the arguments have invalid values.
- class simplebench.reporters.graph.scatterplot.ScatterPlotReporter(
- config: ScatterPlotConfig | None = None,
Bases:
MatPlotLibReporterClass 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_TYPEand_OPTIONS_KWARGS. These must be correctly defined in any subclass ofScatterPlotReporterto 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:
SimpleBenchTypeError – If the subclass configuration types are invalid.
SimpleBenchValueError – If the subclass configuration values are invalid.
- render(
- *,
- case: Case,
- section: Section,
- options: ReporterOptions,
Render the scatter plot graph and return it as bytes.
- Parameters:
case – The
Caseinstance 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:
SimpleBenchTypeError – If the provided arguments are not of the expected types or values.
SimpleBenchValueError – If the provided values are not valid.