simplebench.enums packageπ
Public API for enums.
Enumarations used throughout SimpleBench.
Providesπ
- class simplebench.enums.Color(value)[source]π
-
Colors for console output.
- Defined Colors are:
BLACK: Black color.
RED: Red color.
GREEN: Green color.
YELLOW: Yellow color.
BLUE: Blue color.
MAGENTA: Magenta color.
CYAN: Cyan color.
WHITE: White color.
- BLACK = 'black'π
Black color.
- BLUE = 'blue'π
Blue color.
- CYAN = 'cyan'π
Cyan color.
- GREEN = 'green'π
Green color.
- MAGENTA = 'magenta'π
Magenta color.
- RED = 'red'π
Red color.
- WHITE = 'white'π
White color.
- YELLOW = 'yellow'π
Yellow color.
- class simplebench.enums.ExitCode(value)[source]π
-
Exit codes for SimpleBench CLI.
- Defined Exit Codes are:
SUCCESS: Successful execution.
RUNTIME_ERROR: General runtime error during execution.
CLI_ARGUMENTS_ERROR: Error while processing command line arguments.
KEYBOARD_INTERRUPT: Keyboard interrupt occurred.
BENCHMARK_TIMED_OUT: Benchmark execution timed out.
- BENCHMARK_ERROR = 5π
An error occurred during benchmark execution.
- BENCHMARK_TIMED_OUT = 4π
Benchmark execution timed out.
- CLI_ARGUMENTS_ERROR = 2π
Error while processing command line arguments.
- KEYBOARD_INTERRUPT = 3π
Keyboard interrupt occurred.
- RUNTIME_ERROR = 1π
Runtime error during execution.
- SUCCESS = 0π
Successful execution.
- class simplebench.enums.FlagType(value)[source]π
-
Types of command-line flags for reporters.
- Available FlagTypes are:
BOOLEAN: Boolean flag type.
TARGET_LIST: List of output targets
INVALID: Invalid flag type. This is a testing placeholder and should not be used.
- BOOLEAN = 'boolean'π
Boolean flag type.
This flag type represents a simple on/off or true/false option.
Example: βverbose / βno-verbose
- INVALID = 'invalid'π
Invalid flag type.
This is a testing placeholder and should not be used. It is included to test error handling for unsupported flag types.
- TARGET_LIST = 'target_list'π
List of output targets
This flag type represents a list of output targets for the reporter.
This allows specifying multiple targets for the reporter to output to.
The targets are specified as a list of strings and validated against the allowed Target enum values. It support passing NO targets as well, in which case the reporter will use the default targets.
Example: βjson console filesystem callback
- class simplebench.enums.Format(value)[source]π
-
Categories for different output formats.
- Defined Formats are:
PLAIN_TEXT: Plain text format.
RICH_TEXT: Rich text format.
CSV: CSV format.
JSON: JSON format.
GRAPH: Graphical format.
CUSTOM: Custom format.
- CSV = 'csv'π
CSV format
- CUSTOM = 'custom'π
Custom format
- GRAPH = 'graph'π
Graphical format
- JSON = 'json'π
JSON format
- PLAIN_TEXT = 'plain text'π
Plain text format
- RICH_TEXT = 'rich text'π
Rich text format
- class simplebench.enums.Section(value)[source]π
-
Categories for case results sections in reporters.
This is used by reporters to specify which sections of benchmark results to include in their output.
- Defined Sections are:
OPS: Operations per second section.
TIMING: Time per round section.
MEMORY: Memory usage section.
PEAK_MEMORY: Peak memory usage section.
NULL: No section. This is used when a reporter does not specify a section.
- MEMORY = 'memory usage'π
Memory usage section.
- NULL = 'null section'π
No section. This is used when a reporter does not specify a section.
- OPS = 'operations per second'π
Operations per second section.
- PEAK_MEMORY = 'peak memory usage'π
Peak memory usage section.
- TIMING = 'per round timings'π
Time per round section.
- class simplebench.enums.Target(value)[source]π
-
Categories for different output targets.
The enums are used in generating calling parameters for the report() methods in the Reporter subclasses.
- Defined Targets are:
CONSOLE: Output to console.
FILESYSTEM: Output to filesystem.
CALLBACK: Pass generated output to a callback function.
CUSTOM: Output to a custom target.
NULL: No output.
- CALLBACK = 'callback'π
Pass generated output to a callback function.
- CONSOLE = 'console'π
Output to console.
- CUSTOM = 'custom'π
Output to a custom target.
- FILESYSTEM = 'filesystem'π
Output to filesystem.
- INVALID = 'invalid'π
Invalid target. This is a testing placeholder and should not be used.
- NULL = 'null'π
No output.
- class simplebench.enums.Verbosity(value)[source]π
-
Verbosity level enums for console output.
- Defined levels are:
QUIET: Only requested output, errors, warnings and critical messages are shown.
NORMAL: Normal messages are shown, including status displays during runs.
VERBOSE: All messages are shown and status displays during runs.
DEBUG: All messages are shown, including debug messages and status displays during runs.
- DEBUG = 5π
All messages are shown, including debug messages and status displays during runs.
This is incompatible with quiet.
- NORMAL = 1π
Normal messages are shown, including status displays during runs.
This is the default verbosity level and is incompatible with quiet.
- QUIET = 0π
Only requested output, errors, warnings and critical messages are shown. Status displays are not shown during runs.
This is incompatible with all other output levels.
- VERBOSE = 2π
All messages are shown and status displays during runs.
This is incompatible with quiet.
- simplebench.enums.enum_docstrings(
- enum: type[E],
Attach docstrings to enum members.
Docstrings are string literals that appear directly below the enum member assignment expression within triple-quotes.
This decorator parses the source code of the enum class to find docstrings for each member and attaches them to the respective enum members.
This allows for more detailed documentation of enum members and in tools that can extract and display these docstrings.
This code is adapted from: https://stackoverflow.com/questions/19330460/how-do-i-put-docstrings-on-enums
Example usage of enum_docstrings decoratorπ1@enum_docstrings 2class SomeEnum(Enum): 3 '''Docstring for the SomeEnum enum''' 4 5 foo_member = "foo_value" 6 '''Docstring for the foo_member enum member''' 7 8SomeEnum.foo_member.__doc__ # 'Docstring for the foo_member enum member'
- Parameters:
enum β The enum class to process.
- Returns:
The same enum class with member docstrings attached.