Template Numerical Library version\ main:0b2c40f
Loading...
Searching...
No Matches
TNL::Benchmarks::Logging Class Referenceabstract

Abstract base class for benchmark result loggers. More...

#include <TNL/Benchmarks/Logging.h>

Inheritance diagram for TNL::Benchmarks::Logging:
[legend]
Collaboration diagram for TNL::Benchmarks::Logging:
[legend]

Public Types

using HeaderElements = std::vector< std::string >
using MetadataColumns = std::vector< MetadataElement >
using MetadataElement = std::pair< std::string, std::string >
using RowElements = LoggingRowElements

Public Member Functions

 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 logResult (const std::string &performer, const HeaderElements &headerElements, const RowElements &rowElements, const std::string &errorMessage="")=0
 Logs a benchmark result row.
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.
virtual void writeErrorMessage (const std::string &message)=0
 Logs an error message.

Protected Attributes

bool header_changed = true
std::ostreamlog
MetadataColumns metadataColumns
int verbose = 0

Detailed Description

Abstract base class for benchmark result loggers.

Provides common functionality for logging benchmark results to various outputs (files, terminals, etc.). Supports metadata tracking and configurable verbosity levels.

Constructor & Destructor Documentation

◆ Logging()

TNL::Benchmarks::Logging::Logging ( std::ostream & log,
int verbose = 1 )
inline

Constructs logger with output stream.

Enables exceptions on the output stream for error detection.

Parameters
logOutput stream (file, cout, etc.)
verboseVerbosity level (0=silent, 1=normal, 2=verbose)

Member Function Documentation

◆ getMetadataColumns()

const MetadataColumns & TNL::Benchmarks::Logging::getMetadataColumns ( ) const
inlinenodiscard

Gets current metadata columns.

Returns
Reference to metadata vector

◆ getVerbose()

int TNL::Benchmarks::Logging::getVerbose ( ) const
inlinenodiscard

Gets current verbosity level.

Returns
Verbosity setting

◆ logResult()

virtual void TNL::Benchmarks::Logging::logResult ( const std::string & performer,
const HeaderElements & headerElements,
const RowElements & rowElements,
const std::string & errorMessage = "" )
pure virtual

Logs a benchmark result row.

Must be implemented by derived classes. Called after each measurement.

Parameters
performerName of implementation being tested
headerElementsColumn names
rowElementsFormatted row values
errorMessageOptional error description (empty if success)

Implemented in TNL::Benchmarks::JsonLogging, and TNL::Benchmarks::TerminalLogger.

◆ setMetadataColumns()

virtual void TNL::Benchmarks::Logging::setMetadataColumns ( const MetadataColumns & elements)
inlinevirtual

Sets all metadata columns at once.

Tracks changes to detect when headers need updating.

Parameters
elementsVector of key-value metadata pairs

◆ setMetadataElement()

virtual void TNL::Benchmarks::Logging::setMetadataElement ( const typename MetadataColumns::value_type & element,
int insertPosition = -1 )
inlinevirtual

Updates or adds a single metadata element.

If the key already exists, updates its value. Otherwise adds new entry. Negative insertPosition values count from the end.

Parameters
elementKey-value pair to set
insertPositionInsert position (-1=end, -2=second-to-last, etc.)

◆ setVerbose()

void TNL::Benchmarks::Logging::setVerbose ( int verbose)
inline

Sets verbosity level.

Parameters
verboseVerbosity: 0=silent, 1=normal, 2=verbose

◆ syncMetadata()

void TNL::Benchmarks::Logging::syncMetadata ( Logging & other)
inline

Copies metadata from another logger instance.

Used to synchronize state between multiple loggers.

Parameters
otherSource logger to copy from

◆ writeErrorMessage()

virtual void TNL::Benchmarks::Logging::writeErrorMessage ( const std::string & message)
pure virtual

Logs an error message.

Must be implemented by derived classes. Called when benchmark fails.

Parameters
messageError description

Implemented in TNL::Benchmarks::JsonLogging, and TNL::Benchmarks::TerminalLogger.


The documentation for this class was generated from the following file: