Loading src/TNL/CMakeLists.txt +2 −2 Original line number Diff line number Diff line Loading @@ -35,12 +35,12 @@ set( headers StaticFor.h String.h Timer.h Timer_impl.h StaticVectorFor.h ) set( common_SOURCES FileName.cpp String.cpp Timer.cpp ) String.cpp ) set( tnl_SOURCES ${tnl_config_SOURCES} ${tnl_containers_SOURCES} Loading src/TNL/Timer.h +1 −2 Original line number Diff line number Diff line Loading @@ -132,7 +132,6 @@ class Timer } }; extern Timer defaultTimer; } // namespace TNL #include <TNL/Timer_impl.h> src/TNL/Timer.cpp→src/TNL/Timer_impl.h +15 −15 Original line number Diff line number Diff line /*************************************************************************** Timer.cpp - description Timer_impl.h - description ------------------- begin : Mar 14, 2016 copyright : (C) 2016 by Tomas Oberhuber Loading @@ -8,6 +8,8 @@ /* See Copyright Notice in tnl/Copyright */ #pragma once #include <TNL/Timer.h> #include <TNL/Logger.h> Loading @@ -19,14 +21,12 @@ namespace TNL { Timer defaultTimer; Timer::Timer() inline Timer::Timer() { reset(); } void Timer::reset() inline void Timer::reset() { this->initialCPUTime = 0; this->totalCPUTime = 0.0; Loading @@ -37,7 +37,7 @@ void Timer::reset() this->stopState = true; } void Timer::stop() inline void Timer::stop() { if( ! this->stopState ) Loading @@ -49,7 +49,7 @@ void Timer::stop() } } void Timer::start() inline void Timer::start() { this->initialRealTime = this->readRealTime(); this->initialCPUTime = this->readCPUTime(); Loading @@ -57,33 +57,33 @@ void Timer::start() this->stopState = false; } double Timer::getRealTime() const inline double Timer::getRealTime() const { if( ! this->stopState ) return durationToDouble( this->readRealTime() - this->initialRealTime ); return durationToDouble( this->totalRealTime ); } double Timer::getCPUTime() const inline double Timer::getCPUTime() const { if( ! this->stopState ) return this->readCPUTime() - this->initialCPUTime; return this->totalCPUTime; } unsigned long long int Timer::getCPUCycles() const inline unsigned long long int Timer::getCPUCycles() const { if( ! this->stopState ) return this->readCPUCycles() - this->initialCPUCycles; return this->totalCPUCycles; } typename Timer::TimePoint Timer::readRealTime() const inline typename Timer::TimePoint Timer::readRealTime() const { return std::chrono::high_resolution_clock::now(); } double Timer::readCPUTime() const inline double Timer::readCPUTime() const { #if !defined(_WIN32) && !defined(_WIN64) rusage initUsage; Loading @@ -94,19 +94,19 @@ double Timer::readCPUTime() const #endif } unsigned long long int Timer::readCPUCycles() const inline unsigned long long int Timer::readCPUCycles() const { return this->rdtsc(); } double Timer::durationToDouble( const Duration& duration ) const inline double Timer::durationToDouble( const Duration& duration ) const { std::chrono::duration< double > dur( duration ); return dur.count(); } bool Timer::writeLog( Logger& logger, int logLevel ) const inline bool Timer::writeLog( Logger& logger, int logLevel ) const { logger.writeParameter< double >( "Real time:", this->getRealTime(), logLevel ); logger.writeParameter< double >( "CPU time:", this->getCPUTime(), logLevel ); Loading Loading
src/TNL/CMakeLists.txt +2 −2 Original line number Diff line number Diff line Loading @@ -35,12 +35,12 @@ set( headers StaticFor.h String.h Timer.h Timer_impl.h StaticVectorFor.h ) set( common_SOURCES FileName.cpp String.cpp Timer.cpp ) String.cpp ) set( tnl_SOURCES ${tnl_config_SOURCES} ${tnl_containers_SOURCES} Loading
src/TNL/Timer.h +1 −2 Original line number Diff line number Diff line Loading @@ -132,7 +132,6 @@ class Timer } }; extern Timer defaultTimer; } // namespace TNL #include <TNL/Timer_impl.h>
src/TNL/Timer.cpp→src/TNL/Timer_impl.h +15 −15 Original line number Diff line number Diff line /*************************************************************************** Timer.cpp - description Timer_impl.h - description ------------------- begin : Mar 14, 2016 copyright : (C) 2016 by Tomas Oberhuber Loading @@ -8,6 +8,8 @@ /* See Copyright Notice in tnl/Copyright */ #pragma once #include <TNL/Timer.h> #include <TNL/Logger.h> Loading @@ -19,14 +21,12 @@ namespace TNL { Timer defaultTimer; Timer::Timer() inline Timer::Timer() { reset(); } void Timer::reset() inline void Timer::reset() { this->initialCPUTime = 0; this->totalCPUTime = 0.0; Loading @@ -37,7 +37,7 @@ void Timer::reset() this->stopState = true; } void Timer::stop() inline void Timer::stop() { if( ! this->stopState ) Loading @@ -49,7 +49,7 @@ void Timer::stop() } } void Timer::start() inline void Timer::start() { this->initialRealTime = this->readRealTime(); this->initialCPUTime = this->readCPUTime(); Loading @@ -57,33 +57,33 @@ void Timer::start() this->stopState = false; } double Timer::getRealTime() const inline double Timer::getRealTime() const { if( ! this->stopState ) return durationToDouble( this->readRealTime() - this->initialRealTime ); return durationToDouble( this->totalRealTime ); } double Timer::getCPUTime() const inline double Timer::getCPUTime() const { if( ! this->stopState ) return this->readCPUTime() - this->initialCPUTime; return this->totalCPUTime; } unsigned long long int Timer::getCPUCycles() const inline unsigned long long int Timer::getCPUCycles() const { if( ! this->stopState ) return this->readCPUCycles() - this->initialCPUCycles; return this->totalCPUCycles; } typename Timer::TimePoint Timer::readRealTime() const inline typename Timer::TimePoint Timer::readRealTime() const { return std::chrono::high_resolution_clock::now(); } double Timer::readCPUTime() const inline double Timer::readCPUTime() const { #if !defined(_WIN32) && !defined(_WIN64) rusage initUsage; Loading @@ -94,19 +94,19 @@ double Timer::readCPUTime() const #endif } unsigned long long int Timer::readCPUCycles() const inline unsigned long long int Timer::readCPUCycles() const { return this->rdtsc(); } double Timer::durationToDouble( const Duration& duration ) const inline double Timer::durationToDouble( const Duration& duration ) const { std::chrono::duration< double > dur( duration ); return dur.count(); } bool Timer::writeLog( Logger& logger, int logLevel ) const inline bool Timer::writeLog( Logger& logger, int logLevel ) const { logger.writeParameter< double >( "Real time:", this->getRealTime(), logLevel ); logger.writeParameter< double >( "CPU time:", this->getCPUTime(), logLevel ); Loading