simplebench.reporters.rich_table.reporter package🔗
Rich Table Reporter public API
Provides the following classes:
- RichTableConfig
- RichTableField
- RichTableOptions
- RichTableReporter
- class simplebench.reporters.rich_table.reporter.RichTableConfig(
- *,
- name: str | None = None,
- description: str | None = None,
- sections: set[Section] | None = None,
- targets: set[Target] | None = None,
- default_targets: set[Target] | None = None,
- formats: set[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 RichTableReporter.
This class inherits from
ReporterConfigand provides a type-safe, discoverable interface for overriding the default settings of aRichTableReporter.Initialize the RichTableReporter configuration.
Accepts keyword arguments to override any of the default configurations. All arguments are optional. If not provided, the default value for RichTableReporter will be used.
Note
The parameters of this constructor correspond directly to the parameters of the base
ReporterConfigclass. This design allows users to easily discover and override any configuration option available for the RichTableReporter while maintaining type safety and discoverability through IDEs and documentation tools.To prevent future breakage, avoid using the ‘rc_’, or ‘rich_table_’ prefixes for any new parameters in subclasses as these are reserved for use by SimpleBench.
Default Values:
name:
'rich-table'description:
'Displays benchmark results as a rich text table on the console.'sections:
{Section.OPS, Section.TIMING, Section.MEMORY, Section.PEAK_MEMORY}targets:
{Target.CONSOLE, Target.FILESYSTEM, Target.CALLBACK}default_targets:
{Target.CONSOLE}formats:
{Format.RICH_TEXT}choices: A
ChoicesConfwith predefinedChoiceConfobjects for rich table reporting.file_suffix:
'txt'file_unique:
Falsefile_append:
Truesubdir:
'rich'
- Parameters:
name – The name of the reporter.
description – A brief description of the reporter.
sections – The sections to include in the report.
targets – The output targets for the report.
default_targets – The default output targets if none are specified.
formats – The output formats for the report.
choices – The choice configurations for the reporter.
file_suffix – The file suffix to use for filesystem outputs.
file_unique – Whether to use unique filenames for outputs.
file_append – Whether to append to existing files.
subdir – The subdirectory to use for filesystem outputs.
- Raises:
SimpleBenchTypeError – If any provided argument has an invalid type.
SimpleBenchValueError – If any provided argument has an invalid value or combination of values.
- class simplebench.reporters.rich_table.reporter.RichTableField(value)[source]🔗
-
Fields available for Rich Table reporter output.
- ELAPSED_SECONDS = 'Elapsed Seconds'🔗
The total elapsed time in seconds.
- ITERATIONS = 'Iterations'🔗
The number of iterations performed.
- MAX = 'max'🔗
The statistical maximum value.
- MEAN = 'mean'🔗
The statistical mean value.
- MEDIAN = 'median'🔗
The statistical median value.
- MIN = 'min'🔗
The statistical minimum value.
- N = 'N'🔗
The O() complexity value.
- P5 = '5th'🔗
The statistical 5th percentile.
- P95 = '95th'🔗
The statistical 95th percentile.
- ROUNDS = 'Rounds'🔗
The number of rounds performed.
- RSD_PERCENT = 'rsd%'🔗
The relative standard deviation percentage.
- STD_DEV = 'std dev'🔗
The adjusted standard deviation of operation times.
- class simplebench.reporters.rich_table.reporter.RichTableOptions(
- virtual_width: int | None = None,
- fields: Sequence[RichTableField] | None = None,
- variation_cols_last: bool = False,
Bases:
ReporterOptionsClass for holding Rich table reporter specific options in a Choice.
This class provides additional configuration options specific to the JSON reporter. It is accessed via the
optionsattribute of aChoiceinstance.- Parameters:
virtual_width –
The width of the Rich table output in characters when rendered to the filesystem or via callback. Must be between 80 and 1000 characters or
None. IfNone, no width constraint is applied.The virtual width is used to determine how the table should be formatted when rendered to non-console outputs, such as files or callbacks. This allows for better control over the appearance of the table in different contexts.
fields –
A tuple of Rich Table fields to include in the output. If none is specifically set, a predefined set of fields is used. The fields appear in the order specified in the sequence.
If specified, all fields must be from the
RichTableFieldenum.The default fields, in order, are:
variation_cols_last – Whether to place the variation columns (if any) at the end of the rows. Defaults to
False- which places the variation columns at the start of the rows.
- Raises:
SimpleBenchTypeError – If any parameter is of an invalid type.
SimpleBenchValueError – If
virtual_widthis not between 80 and 10000 characters when specified or iffieldsis an empty sequence.
Initialize RichTableOptions instance.
- property fields: tuple[RichTableField, ...]🔗
Return the fields, in order, to include in the Rich table when rendering.
- Returns:
A tuple of RichTableField enums representing the default fields.
- class simplebench.reporters.rich_table.reporter.RichTableReporter(
- config: RichTableConfig | None = None,
Bases:
ReporterClass for outputting benchmark results as Rich Tables.
It supports reporting operations per second and per round timing results, either separately or together, to the console, to files, and/or via a callback function.
Defined command-line flags:
--rich-table: Outputs all results as rich text tables on the console.--rich-table.ops: Outputs only operations per second results.--rich-table.timings: Outputs only per round timing results.--rich-table.memory: Outputs only memory usage results.--rich-table.peak-memory: Outputs only peak memory usage results.
Each flag supports multiple targets:
console,filesystem, andcallbackwith the default target beingconsole.- Variables:
name (str) – The unique identifying name of the reporter.
description (str) – A brief description of the reporter.
choices (Choices) – A collection of
Choicesinstances defining the reporter instance, CLI flags,Choicename, supportedSectionobjects, supported outputTargetobjects, and supported outputFormatobjects for the reporter.
Initialize the RichTableReporter.
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 ofRichTableReporterto ensure proper functionality.In simple use, these exceptions should never be raised, as
RichTableReporterprovides valid implementations. They are documented here for completeness.- Parameters:
config (RichTableConfig | 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,
Prints the benchmark results in a rich table format if available.
It creates a
Tableinstance containing the benchmark results for the specified section.The table includes the fields specified in the options argument, formatted appropriately based on the results data.
Depending on the options, variation columns can be placed at the start or end of the rows.
- Parameters:
case – The
Caseinstance representing the benchmarked code.options – The options specifying the report configuration. (
RichTableOptionsis a subclass ofReporterOptions.)section – The
Sectionenum value specifying the type of results to display.
- Returns:
The
Tableinstance.