Loading src/Benchmarks/Benchmarks.h +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ class Benchmark // Adds an error message to the log. Should be called in places where the // "time" method could not be called (e.g. due to failed allocation). void addErrorMessage( const char* msg ); void addErrorMessage( const std::string& message ); bool save( std::ostream& logFile ); Loading src/Benchmarks/Benchmarks.hpp +7 −5 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ time( ResetFunction reset, // stop the main loop when not verbose monitor.stopMainLoop(); std::string errorMessage; try { if( this->reset ) std::tie( result.time, result.stddev ) = functionTimer.timeFunction( compute, reset, loops, minTime, monitor ); Loading @@ -164,7 +165,8 @@ time( ResetFunction reset, this->performedLoops = functionTimer.getPerformedLoops(); } catch ( const std::exception& e ) { std::cerr << "timeFunction failed due to a C++ exception with description: " << e.what() << std::endl; errorMessage = "timeFunction failed due to a C++ exception with description: " + std::string(e.what()); std::cerr << errorMessage << std::endl; } result.bandwidth = datasetSize / result.time; Loading @@ -172,7 +174,7 @@ time( ResetFunction reset, if( this->baseTime == 0.0 ) this->baseTime = result.time; logger.logResult( performer, result.getTableHeader(), result.getRowElements(), result.getColumnWidthHints() ); logger.logResult( performer, result.getTableHeader(), result.getRowElements(), result.getColumnWidthHints(), errorMessage ); return this->baseTime; } Loading Loading @@ -219,10 +221,10 @@ time( const String & performer, template< typename Logger > void Benchmark< Logger >:: addErrorMessage( const char* msg ) addErrorMessage( const std::string& message ) { logger.writeErrorMessage( msg ); std::cerr << msg << std::endl; logger.writeErrorMessage( message ); std::cerr << message << std::endl; } template< typename Logger > Loading src/Benchmarks/CustomLogging.h +15 −7 Original line number Diff line number Diff line Loading @@ -122,7 +122,8 @@ public: void writeTableRow( const std::string & spanningElement, const RowElements & subElements ) const RowElements & subElements, const std::string & errorMessage ) { if( verbose ) { for( auto & it : metadataColumns ) { Loading @@ -142,23 +143,30 @@ public: log << it.second << std::endl; } if( errorMessage.empty() ) { // benchmark data are indented const std::string indent = " "; for( auto & it : subElements ) { log << indent << it << std::endl; } } else { // write the message log << errorMessage << std::endl; } } virtual void logResult( const std::string& spanningElement, const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& columnWidthHints ) override const WidthHints& columnWidthHints, const std::string& errorMessage = "" ) override { TNL_ASSERT_EQ( headerElements.size(), rowElements.size(), "elements must have equal sizes" ); TNL_ASSERT_EQ( headerElements.size(), columnWidthHints.size(), "elements must have equal sizes" ); writeTableHeader( spanningElement, headerElements ); writeTableRow( spanningElement, rowElements ); writeTableRow( spanningElement, rowElements, errorMessage ); } virtual void Loading src/Benchmarks/JsonLogging.h +32 −4 Original line number Diff line number Diff line Loading @@ -106,7 +106,10 @@ public: } } void writeRow( const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& widths ) void writeRow( const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& widths, const std::string& errorMessage ) { TNL_ASSERT_EQ( headerElements.size(), rowElements.size(), "elements must have equal sizes" ); TNL_ASSERT_EQ( headerElements.size(), widths.size(), "elements must have equal sizes" ); Loading Loading @@ -136,6 +139,11 @@ public: log << " \"" << headerElements[ i ] << "\" : \"" << el << "\""; i++; } if( ! errorMessage.empty() ) { if( idx++ > 0 ) log << "," << std::endl; log << " \"error\" : \"" << errorMessage << "\""; } log << std::endl << " }"; this->lineStarted = true; if( verbose ) Loading @@ -146,16 +154,36 @@ public: logResult( const std::string& spanningElement, const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& columnWidthHints ) override const WidthHints& columnWidthHints, const std::string& errorMessage = "" ) override { writeHeader( headerElements, columnWidthHints ); writeRow( headerElements, rowElements, columnWidthHints ); writeRow( headerElements, rowElements, columnWidthHints, errorMessage ); } virtual void writeErrorMessage( const std::string& message ) override { log << "\"error\" : \"" << message << "\"" << std::endl; if( this->lineStarted ) log << "," << std::endl; log << " {" << std::endl; // write common logs int idx( 0 ); for( auto lg : this->metadataColumns ) { if( idx++ > 0 ) log << "," << std::endl; log << " \"" << lg.first << "\" : \"" << lg.second << "\""; } if( idx++ > 0 ) log << "," << std::endl; log << " \"error\" : \"" << message << "\""; log << std::endl << " }"; this->lineStarted = true; } virtual void Loading src/Benchmarks/Logging.h +2 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,8 @@ public: logResult( const std::string& spanningElement, const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& columnWidthHints ) = 0; const WidthHints& columnWidthHints, const std::string& errorMessage = "" ) = 0; virtual void writeErrorMessage( const std::string& message ) = 0; Loading Loading
src/Benchmarks/Benchmarks.h +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ class Benchmark // Adds an error message to the log. Should be called in places where the // "time" method could not be called (e.g. due to failed allocation). void addErrorMessage( const char* msg ); void addErrorMessage( const std::string& message ); bool save( std::ostream& logFile ); Loading
src/Benchmarks/Benchmarks.hpp +7 −5 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ time( ResetFunction reset, // stop the main loop when not verbose monitor.stopMainLoop(); std::string errorMessage; try { if( this->reset ) std::tie( result.time, result.stddev ) = functionTimer.timeFunction( compute, reset, loops, minTime, monitor ); Loading @@ -164,7 +165,8 @@ time( ResetFunction reset, this->performedLoops = functionTimer.getPerformedLoops(); } catch ( const std::exception& e ) { std::cerr << "timeFunction failed due to a C++ exception with description: " << e.what() << std::endl; errorMessage = "timeFunction failed due to a C++ exception with description: " + std::string(e.what()); std::cerr << errorMessage << std::endl; } result.bandwidth = datasetSize / result.time; Loading @@ -172,7 +174,7 @@ time( ResetFunction reset, if( this->baseTime == 0.0 ) this->baseTime = result.time; logger.logResult( performer, result.getTableHeader(), result.getRowElements(), result.getColumnWidthHints() ); logger.logResult( performer, result.getTableHeader(), result.getRowElements(), result.getColumnWidthHints(), errorMessage ); return this->baseTime; } Loading Loading @@ -219,10 +221,10 @@ time( const String & performer, template< typename Logger > void Benchmark< Logger >:: addErrorMessage( const char* msg ) addErrorMessage( const std::string& message ) { logger.writeErrorMessage( msg ); std::cerr << msg << std::endl; logger.writeErrorMessage( message ); std::cerr << message << std::endl; } template< typename Logger > Loading
src/Benchmarks/CustomLogging.h +15 −7 Original line number Diff line number Diff line Loading @@ -122,7 +122,8 @@ public: void writeTableRow( const std::string & spanningElement, const RowElements & subElements ) const RowElements & subElements, const std::string & errorMessage ) { if( verbose ) { for( auto & it : metadataColumns ) { Loading @@ -142,23 +143,30 @@ public: log << it.second << std::endl; } if( errorMessage.empty() ) { // benchmark data are indented const std::string indent = " "; for( auto & it : subElements ) { log << indent << it << std::endl; } } else { // write the message log << errorMessage << std::endl; } } virtual void logResult( const std::string& spanningElement, const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& columnWidthHints ) override const WidthHints& columnWidthHints, const std::string& errorMessage = "" ) override { TNL_ASSERT_EQ( headerElements.size(), rowElements.size(), "elements must have equal sizes" ); TNL_ASSERT_EQ( headerElements.size(), columnWidthHints.size(), "elements must have equal sizes" ); writeTableHeader( spanningElement, headerElements ); writeTableRow( spanningElement, rowElements ); writeTableRow( spanningElement, rowElements, errorMessage ); } virtual void Loading
src/Benchmarks/JsonLogging.h +32 −4 Original line number Diff line number Diff line Loading @@ -106,7 +106,10 @@ public: } } void writeRow( const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& widths ) void writeRow( const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& widths, const std::string& errorMessage ) { TNL_ASSERT_EQ( headerElements.size(), rowElements.size(), "elements must have equal sizes" ); TNL_ASSERT_EQ( headerElements.size(), widths.size(), "elements must have equal sizes" ); Loading Loading @@ -136,6 +139,11 @@ public: log << " \"" << headerElements[ i ] << "\" : \"" << el << "\""; i++; } if( ! errorMessage.empty() ) { if( idx++ > 0 ) log << "," << std::endl; log << " \"error\" : \"" << errorMessage << "\""; } log << std::endl << " }"; this->lineStarted = true; if( verbose ) Loading @@ -146,16 +154,36 @@ public: logResult( const std::string& spanningElement, const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& columnWidthHints ) override const WidthHints& columnWidthHints, const std::string& errorMessage = "" ) override { writeHeader( headerElements, columnWidthHints ); writeRow( headerElements, rowElements, columnWidthHints ); writeRow( headerElements, rowElements, columnWidthHints, errorMessage ); } virtual void writeErrorMessage( const std::string& message ) override { log << "\"error\" : \"" << message << "\"" << std::endl; if( this->lineStarted ) log << "," << std::endl; log << " {" << std::endl; // write common logs int idx( 0 ); for( auto lg : this->metadataColumns ) { if( idx++ > 0 ) log << "," << std::endl; log << " \"" << lg.first << "\" : \"" << lg.second << "\""; } if( idx++ > 0 ) log << "," << std::endl; log << " \"error\" : \"" << message << "\""; log << std::endl << " }"; this->lineStarted = true; } virtual void Loading
src/Benchmarks/Logging.h +2 −1 Original line number Diff line number Diff line Loading @@ -114,7 +114,8 @@ public: logResult( const std::string& spanningElement, const HeaderElements& headerElements, const RowElements& rowElements, const WidthHints& columnWidthHints ) = 0; const WidthHints& columnWidthHints, const std::string& errorMessage = "" ) = 0; virtual void writeErrorMessage( const std::string& message ) = 0; Loading