|
Template Numerical Library version\ main:0b2c40f
|
Logger that outputs benchmark results as JSON lines (JSONL). More...
#include <TNL/Benchmarks/JsonLogging.h>
Public Member Functions | |
| JsonLogging (std::ostream &log, int verbose=1) | |
| Constructs JSON logger. | |
| void | logResult (const std::string &performer, const HeaderElements &headerElements, const RowElements &rowElements, const std::string &errorMessage="") override |
| Logs a benchmark result as JSON. | |
| void | writeErrorMessage (const std::string &message) override |
| Logs an error message as JSON. | |
| void | writeRow (const HeaderElements &headerElements, const RowElements &rowElements, const std::string &errorMessage) |
| Writes a single result row as JSON. | |
| Public Member Functions inherited from TNL::Benchmarks::Logging | |
| Logging (std::ostream &log, int verbose=1) | |
| Constructs logger with output stream. | |
| const MetadataColumns & | getMetadataColumns () const |
| Gets current metadata columns. | |
| int | getVerbose () const |
| Gets current verbosity level. | |
| virtual void | setMetadataColumns (const MetadataColumns &elements) |
| Sets all metadata columns at once. | |
| virtual void | setMetadataElement (const typename MetadataColumns::value_type &element, int insertPosition=-1) |
| Updates or adds a single metadata element. | |
| void | setVerbose (int verbose) |
| Sets verbosity level. | |
| void | syncMetadata (Logging &other) |
| Copies metadata from another logger instance. | |
Static Protected Member Functions | |
| static std::string | escape_json (const std::string &s) |
Additional Inherited Members | |
| Public Types inherited from TNL::Benchmarks::Logging | |
| using | HeaderElements = std::vector< std::string > |
| using | MetadataColumns = std::vector< MetadataElement > |
| using | MetadataElement = std::pair< std::string, std::string > |
| using | RowElements = LoggingRowElements |
| Protected Attributes inherited from TNL::Benchmarks::Logging | |
| bool | header_changed = true |
| std::ostream & | log |
| MetadataColumns | metadataColumns |
| int | verbose = 0 |
Logger that outputs benchmark results as JSON lines (JSONL).
Each result is written as a separate JSON object on its own line, making it easy to parse and process with standard tools. See https://jsonltools.com/what-is-jsonl for details.
Output format example:
Error messages are also logged as JSON objects with an "error" field.
|
inline |
Constructs JSON logger.
| log | Output stream for JSONL data |
| verbose | Verbosity level (passed to base class, not used by this class) |
|
inlineoverridevirtual |
Logs a benchmark result as JSON.
Adds performer metadata and writes the result row.
| performer | Name of implementation being tested |
| headerElements | Column names |
| rowElements | Formatted row values |
| errorMessage | Optional error description |
Implements TNL::Benchmarks::Logging.
|
inlineoverridevirtual |
Logs an error message as JSON.
Outputs current metadata plus an "error" field containing the message.
| message | Error description |
Implements TNL::Benchmarks::Logging.
|
inline |
Writes a single result row as JSON.
Outputs all metadata columns followed by result values, each as key-value pairs in the JSON object.
| headerElements | Column names |
| rowElements | Formatted row values |
| errorMessage | Optional error description |