mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add timing support to logger
This commit is contained in:
parent
924687b11e
commit
95365ad5d0
@ -169,7 +169,8 @@ void RiaDefaultConsoleLogger::writeToConsole( const std::string& str )
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
std::vector<std::unique_ptr<RiaLogger>> RiaLogging::sm_logger;
|
||||
std::vector<std::unique_ptr<RiaLogger>> RiaLogging::sm_logger;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> RiaLogging::sm_startTime;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -276,6 +277,29 @@ void RiaLogging::errorInMessageBox( QWidget* parent, const QString& title, const
|
||||
RiaLogging::error( text );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::resetTimer( const QString& message )
|
||||
{
|
||||
sm_startTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if ( !message.isEmpty() ) RiaLogging::debug( message );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaLogging::logTimeElapsed( const QString& message )
|
||||
{
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( end - sm_startTime );
|
||||
auto text = message + QString( " (duration : %1 milliseconds)" ).arg( duration.count() );
|
||||
|
||||
RiaLogging::debug( text );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -72,8 +73,12 @@ public:
|
||||
|
||||
static void errorInMessageBox( QWidget* parent, const QString& title, const QString& text );
|
||||
|
||||
static void resetTimer( const QString& message );
|
||||
static void logTimeElapsed( const QString& message );
|
||||
|
||||
private:
|
||||
static std::vector<std::unique_ptr<RiaLogger>> sm_logger;
|
||||
static std::vector<std::unique_ptr<RiaLogger>> sm_logger;
|
||||
static std::chrono::time_point<std::chrono::high_resolution_clock> sm_startTime;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user