Loading src/Benchmarks/CustomLogging.h +13 −11 Original line number Diff line number Diff line Loading @@ -23,13 +23,13 @@ class CustomLogging { public: CustomLogging( int verbose = true, String outputMode = "", std::string outputMode = "", bool logFileAppend = false ) : Logging(verbose), outputMode( outputMode ) {} virtual void writeTitle( const String & title ) override writeTitle( const std::string & title ) override { if( verbose ) std::cout << std::endl << "== " << title << " ==" << std::endl << std::endl; Loading Loading @@ -61,7 +61,7 @@ public: } virtual void writeTableHeader( const String & spanningElement, writeTableHeader( const std::string & spanningElement, const HeaderElements & subElements ) override { if( verbose && header_changed ) { Loading Loading @@ -94,7 +94,7 @@ public: } virtual void writeTableRow( const String & spanningElement, writeTableRow( const std::string & spanningElement, const RowElements & subElements ) override { if( verbose ) { Loading @@ -116,14 +116,14 @@ public: } // benchmark data are indented const String indent = " "; const std::string indent = " "; for( auto & it : subElements ) { log << indent << it << std::endl; } } virtual void writeErrorMessage( const char* msg ) override writeErrorMessage( const std::string& message ) override { // initial indent string log << std::endl; Loading @@ -136,7 +136,9 @@ public: for( auto & it : metadataColumns ) { log << it.second << std::endl; } log << msg << std::endl; // write the message log << message << std::endl; } virtual void Loading @@ -158,8 +160,8 @@ public: } protected: // manual double -> String conversion with fixed precision static String // manual double -> string conversion with fixed precision static std::string _to_string( double num, int precision = 0, bool fixed = false ) { std::stringstream str; Loading @@ -168,7 +170,7 @@ protected: if( precision ) str << std::setprecision( precision ); str << num; return String( str.str().data() ); return std::string( str.str().data() ); } std::stringstream log; Loading @@ -176,7 +178,7 @@ protected: MetadataColumns metadataColumns; bool header_changed = true; String outputMode; std::string outputMode; }; } // namespace Benchmarks Loading src/Benchmarks/JsonLogging.h +10 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ class JsonLogging { public: JsonLogging( int verbose = true, String outputMode = "", std::string outputMode = "", bool logFileAppend = false ) : Logging(verbose), outputMode( outputMode ), logFileAppend( logFileAppend ) {} Loading Loading @@ -97,7 +97,7 @@ public: } virtual void writeTitle( const String & title ) override writeTitle( const std::string & title ) override { if( outputMode == "append" ) return; Loading Loading @@ -125,22 +125,22 @@ public: } virtual void writeTableHeader( const String & spanningElement, writeTableHeader( const std::string & spanningElement, const HeaderElements & subElements ) override { } virtual void writeTableRow( const String & spanningElement, writeTableRow( const std::string & spanningElement, const RowElements & subElements ) override { writeRow( subElements ); } virtual void writeErrorMessage( const char* msg ) override writeErrorMessage( const std::string& message ) override { log << "\"error\" : \"" << msg << "\"" << std::endl; log << "\"error\" : \"" << message << "\"" << std::endl; } virtual void Loading @@ -165,8 +165,8 @@ public: } protected: // manual double -> String conversion with fixed precision static String // manual double -> string conversion with fixed precision static std::string _to_string( double num, int precision = 0, bool fixed = false ) { std::stringstream str; Loading @@ -175,7 +175,7 @@ protected: if( precision ) str << std::setprecision( precision ); str << num; return String( str.str().data() ); return std::string( str.str().data() ); } std::stringstream log; Loading @@ -184,7 +184,7 @@ protected: LogsMetadata logsMetadata; WidthHints widthHints; CommonLogs commonLogs; String outputMode; std::string outputMode; bool lineStarted = false; bool resultsStarted = false; Loading src/Benchmarks/Logging.h +13 −15 Original line number Diff line number Diff line Loading @@ -21,8 +21,6 @@ #include <string> #include <sstream> #include <TNL/String.h> namespace TNL { namespace Benchmarks { Loading Loading @@ -72,7 +70,7 @@ class LoggingRowElements auto cend() const noexcept { return elements.cend(); } protected: std::list< String > elements; std::list< std::string > elements; std::stringstream stream; }; Loading @@ -80,14 +78,14 @@ class LoggingRowElements class Logging { public: using MetadataElement = std::pair< const char*, String >; using MetadataMap = std::map< const char*, String >; using MetadataElement = std::pair< std::string, std::string >; using MetadataMap = std::map< std::string, std::string >; using MetadataColumns = std::vector< MetadataElement >; using HeaderElements = std::vector< String >; using HeaderElements = std::vector< std::string >; using RowElements = LoggingRowElements; using CommonLogs = std::vector< std::pair< const char*, String > >; using CommonLogs = MetadataColumns; using LogsMetadata = HeaderElements; using WidthHints = std::vector< int >; Loading @@ -106,7 +104,7 @@ public: return verbose; } virtual void writeTitle( const String & title ) = 0; virtual void writeTitle( const std::string& title ) = 0; virtual void addCommonLogs( const CommonLogs& logs ) = 0; Loading @@ -119,15 +117,15 @@ public: virtual void writeMetadata( const MetadataMap & metadata ) {} virtual void writeTableHeader( const String & spanningElement, writeTableHeader( const std::string& spanningElement, const HeaderElements& subElements ) = 0; virtual void writeTableRow( const String & spanningElement, writeTableRow( const std::string& spanningElement, const RowElements& subElements ) = 0; virtual void writeErrorMessage( const char* msg ) = 0; writeErrorMessage( const std::string& message ) = 0; virtual void closeTable() = 0; Loading Loading
src/Benchmarks/CustomLogging.h +13 −11 Original line number Diff line number Diff line Loading @@ -23,13 +23,13 @@ class CustomLogging { public: CustomLogging( int verbose = true, String outputMode = "", std::string outputMode = "", bool logFileAppend = false ) : Logging(verbose), outputMode( outputMode ) {} virtual void writeTitle( const String & title ) override writeTitle( const std::string & title ) override { if( verbose ) std::cout << std::endl << "== " << title << " ==" << std::endl << std::endl; Loading Loading @@ -61,7 +61,7 @@ public: } virtual void writeTableHeader( const String & spanningElement, writeTableHeader( const std::string & spanningElement, const HeaderElements & subElements ) override { if( verbose && header_changed ) { Loading Loading @@ -94,7 +94,7 @@ public: } virtual void writeTableRow( const String & spanningElement, writeTableRow( const std::string & spanningElement, const RowElements & subElements ) override { if( verbose ) { Loading @@ -116,14 +116,14 @@ public: } // benchmark data are indented const String indent = " "; const std::string indent = " "; for( auto & it : subElements ) { log << indent << it << std::endl; } } virtual void writeErrorMessage( const char* msg ) override writeErrorMessage( const std::string& message ) override { // initial indent string log << std::endl; Loading @@ -136,7 +136,9 @@ public: for( auto & it : metadataColumns ) { log << it.second << std::endl; } log << msg << std::endl; // write the message log << message << std::endl; } virtual void Loading @@ -158,8 +160,8 @@ public: } protected: // manual double -> String conversion with fixed precision static String // manual double -> string conversion with fixed precision static std::string _to_string( double num, int precision = 0, bool fixed = false ) { std::stringstream str; Loading @@ -168,7 +170,7 @@ protected: if( precision ) str << std::setprecision( precision ); str << num; return String( str.str().data() ); return std::string( str.str().data() ); } std::stringstream log; Loading @@ -176,7 +178,7 @@ protected: MetadataColumns metadataColumns; bool header_changed = true; String outputMode; std::string outputMode; }; } // namespace Benchmarks Loading
src/Benchmarks/JsonLogging.h +10 −10 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ class JsonLogging { public: JsonLogging( int verbose = true, String outputMode = "", std::string outputMode = "", bool logFileAppend = false ) : Logging(verbose), outputMode( outputMode ), logFileAppend( logFileAppend ) {} Loading Loading @@ -97,7 +97,7 @@ public: } virtual void writeTitle( const String & title ) override writeTitle( const std::string & title ) override { if( outputMode == "append" ) return; Loading Loading @@ -125,22 +125,22 @@ public: } virtual void writeTableHeader( const String & spanningElement, writeTableHeader( const std::string & spanningElement, const HeaderElements & subElements ) override { } virtual void writeTableRow( const String & spanningElement, writeTableRow( const std::string & spanningElement, const RowElements & subElements ) override { writeRow( subElements ); } virtual void writeErrorMessage( const char* msg ) override writeErrorMessage( const std::string& message ) override { log << "\"error\" : \"" << msg << "\"" << std::endl; log << "\"error\" : \"" << message << "\"" << std::endl; } virtual void Loading @@ -165,8 +165,8 @@ public: } protected: // manual double -> String conversion with fixed precision static String // manual double -> string conversion with fixed precision static std::string _to_string( double num, int precision = 0, bool fixed = false ) { std::stringstream str; Loading @@ -175,7 +175,7 @@ protected: if( precision ) str << std::setprecision( precision ); str << num; return String( str.str().data() ); return std::string( str.str().data() ); } std::stringstream log; Loading @@ -184,7 +184,7 @@ protected: LogsMetadata logsMetadata; WidthHints widthHints; CommonLogs commonLogs; String outputMode; std::string outputMode; bool lineStarted = false; bool resultsStarted = false; Loading
src/Benchmarks/Logging.h +13 −15 Original line number Diff line number Diff line Loading @@ -21,8 +21,6 @@ #include <string> #include <sstream> #include <TNL/String.h> namespace TNL { namespace Benchmarks { Loading Loading @@ -72,7 +70,7 @@ class LoggingRowElements auto cend() const noexcept { return elements.cend(); } protected: std::list< String > elements; std::list< std::string > elements; std::stringstream stream; }; Loading @@ -80,14 +78,14 @@ class LoggingRowElements class Logging { public: using MetadataElement = std::pair< const char*, String >; using MetadataMap = std::map< const char*, String >; using MetadataElement = std::pair< std::string, std::string >; using MetadataMap = std::map< std::string, std::string >; using MetadataColumns = std::vector< MetadataElement >; using HeaderElements = std::vector< String >; using HeaderElements = std::vector< std::string >; using RowElements = LoggingRowElements; using CommonLogs = std::vector< std::pair< const char*, String > >; using CommonLogs = MetadataColumns; using LogsMetadata = HeaderElements; using WidthHints = std::vector< int >; Loading @@ -106,7 +104,7 @@ public: return verbose; } virtual void writeTitle( const String & title ) = 0; virtual void writeTitle( const std::string& title ) = 0; virtual void addCommonLogs( const CommonLogs& logs ) = 0; Loading @@ -119,15 +117,15 @@ public: virtual void writeMetadata( const MetadataMap & metadata ) {} virtual void writeTableHeader( const String & spanningElement, writeTableHeader( const std::string& spanningElement, const HeaderElements& subElements ) = 0; virtual void writeTableRow( const String & spanningElement, writeTableRow( const std::string& spanningElement, const RowElements& subElements ) = 0; virtual void writeErrorMessage( const char* msg ) = 0; writeErrorMessage( const std::string& message ) = 0; virtual void closeTable() = 0; Loading