Loading CMakeLists.txt +0 −12 Original line number Diff line number Diff line Loading @@ -312,18 +312,6 @@ endif() #### # Check for some system header # find_path( SYS_TIME_INCLUDE_DIR sys/time.h /usr/include/x86_64-linux-gnu /usr/include DOC "System timer headers." ) if( ${SYS_TIME_INCLUDE_DIR} STREQUAL "SYS_TIME_INCLUDE_DIR-NOTFOUND" ) message( "Missing header file sys/time.h" ) set( HAVE_SYS_TIME_H "//#define HAVE_SYS_TIME_H 1" ) else() #include_directories( ${SYS_TIME_INCLUDE_DIR} ) set( HAVE_SYS_TIME_H "#define HAVE_SYS_TIME_H 1" ) endif() find_path( SYS_RESOURCE_INCLUDE_DIR sys/resource.h /usr/include/x86_64-linux-gnu /usr/include Loading src/TNL/Timer.cpp +14 −19 Original line number Diff line number Diff line Loading @@ -15,11 +15,6 @@ #ifdef HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif #ifdef HAVE_SYS_TIME_H #include <stddef.h> #include <sys/time.h> #define HAVE_TIME #endif namespace TNL { Loading @@ -34,8 +29,8 @@ void Timer::reset() { this->initialCPUTime = 0; this->totalCPUTime = 0.0; this->initialRealTime = 0; this->totalRealTime = 0.0; this->initialRealTime = TimePoint(); this->totalRealTime = Duration(); this->initialCPUCycles = 0; this->totalCPUCycles = 0; this->stopState = true; Loading Loading @@ -64,8 +59,8 @@ void Timer::start() double Timer::getRealTime() const { if( ! this->stopState ) return this->readRealTime() - this->initialRealTime; return this->totalRealTime; return durationToDouble( this->readRealTime() - this->initialRealTime ); return durationToDouble( this->totalRealTime ); } double Timer::getCPUTime() const Loading @@ -82,15 +77,9 @@ unsigned long long int Timer::getCPUCycles() const return this->totalCPUCycles; } double Timer::readRealTime() const typename Timer::TimePoint Timer::readRealTime() const { #ifdef HAVE_TIME struct timeval tp; int rtn = gettimeofday( &tp, NULL ); return ( double ) tp. tv_sec + 1.0e-6 * ( double ) tp. tv_usec; #else return -1; #endif return std::chrono::high_resolution_clock::now(); } double Timer::readCPUTime() const Loading @@ -109,6 +98,12 @@ unsigned long long int Timer::readCPUCycles() const return this->rdtsc(); } double Timer::durationToDouble( const Duration& duration ) const { std::chrono::duration< double > dur( duration ); return dur.count(); } bool Timer::writeLog( Logger& logger, int logLevel ) const { Loading src/TNL/Timer.h +14 −10 Original line number Diff line number Diff line Loading @@ -8,9 +8,10 @@ /* See Copyright Notice in tnl/Copyright */ #pragma once #include <chrono> namespace TNL { class Logger; Loading Loading @@ -91,10 +92,11 @@ class Timer protected: using TimePoint = typename std::chrono::high_resolution_clock::time_point; using Duration = typename std::chrono::high_resolution_clock::duration; /// \brief Function for measuring the real time. /// /// Returns number of seconds since Epoch, 1970-01-01 00:00:00 UTC. double readRealTime() const; TimePoint readRealTime() const; /// \brief Function for measuring the CPU time. /// Loading @@ -105,9 +107,12 @@ class Timer /// \brief Function for counting the number of CPU cycles (machine cycles). unsigned long long int readCPUCycles() const; double durationToDouble( const Duration& duration ) const; TimePoint initialRealTime; Duration totalRealTime; double initialRealTime, totalRealTime, initialCPUTime, totalCPUTime; double initialCPUTime, totalCPUTime; unsigned long long int initialCPUCycles, totalCPUCycles; Loading @@ -127,7 +132,6 @@ class Timer } }; // !!! Odstranit ???!!! extern Timer defaultTimer; } // namespace TNL Loading tnlConfig.h.in +0 −2 Original line number Diff line number Diff line @HAVE_SYS_TIME_H@ @HAVE_SYS_RESOURCE_H@ @HAVE_SYS_IOCTL_H@ Loading Loading
CMakeLists.txt +0 −12 Original line number Diff line number Diff line Loading @@ -312,18 +312,6 @@ endif() #### # Check for some system header # find_path( SYS_TIME_INCLUDE_DIR sys/time.h /usr/include/x86_64-linux-gnu /usr/include DOC "System timer headers." ) if( ${SYS_TIME_INCLUDE_DIR} STREQUAL "SYS_TIME_INCLUDE_DIR-NOTFOUND" ) message( "Missing header file sys/time.h" ) set( HAVE_SYS_TIME_H "//#define HAVE_SYS_TIME_H 1" ) else() #include_directories( ${SYS_TIME_INCLUDE_DIR} ) set( HAVE_SYS_TIME_H "#define HAVE_SYS_TIME_H 1" ) endif() find_path( SYS_RESOURCE_INCLUDE_DIR sys/resource.h /usr/include/x86_64-linux-gnu /usr/include Loading
src/TNL/Timer.cpp +14 −19 Original line number Diff line number Diff line Loading @@ -15,11 +15,6 @@ #ifdef HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif #ifdef HAVE_SYS_TIME_H #include <stddef.h> #include <sys/time.h> #define HAVE_TIME #endif namespace TNL { Loading @@ -34,8 +29,8 @@ void Timer::reset() { this->initialCPUTime = 0; this->totalCPUTime = 0.0; this->initialRealTime = 0; this->totalRealTime = 0.0; this->initialRealTime = TimePoint(); this->totalRealTime = Duration(); this->initialCPUCycles = 0; this->totalCPUCycles = 0; this->stopState = true; Loading Loading @@ -64,8 +59,8 @@ void Timer::start() double Timer::getRealTime() const { if( ! this->stopState ) return this->readRealTime() - this->initialRealTime; return this->totalRealTime; return durationToDouble( this->readRealTime() - this->initialRealTime ); return durationToDouble( this->totalRealTime ); } double Timer::getCPUTime() const Loading @@ -82,15 +77,9 @@ unsigned long long int Timer::getCPUCycles() const return this->totalCPUCycles; } double Timer::readRealTime() const typename Timer::TimePoint Timer::readRealTime() const { #ifdef HAVE_TIME struct timeval tp; int rtn = gettimeofday( &tp, NULL ); return ( double ) tp. tv_sec + 1.0e-6 * ( double ) tp. tv_usec; #else return -1; #endif return std::chrono::high_resolution_clock::now(); } double Timer::readCPUTime() const Loading @@ -109,6 +98,12 @@ unsigned long long int Timer::readCPUCycles() const return this->rdtsc(); } double Timer::durationToDouble( const Duration& duration ) const { std::chrono::duration< double > dur( duration ); return dur.count(); } bool Timer::writeLog( Logger& logger, int logLevel ) const { Loading
src/TNL/Timer.h +14 −10 Original line number Diff line number Diff line Loading @@ -8,9 +8,10 @@ /* See Copyright Notice in tnl/Copyright */ #pragma once #include <chrono> namespace TNL { class Logger; Loading Loading @@ -91,10 +92,11 @@ class Timer protected: using TimePoint = typename std::chrono::high_resolution_clock::time_point; using Duration = typename std::chrono::high_resolution_clock::duration; /// \brief Function for measuring the real time. /// /// Returns number of seconds since Epoch, 1970-01-01 00:00:00 UTC. double readRealTime() const; TimePoint readRealTime() const; /// \brief Function for measuring the CPU time. /// Loading @@ -105,9 +107,12 @@ class Timer /// \brief Function for counting the number of CPU cycles (machine cycles). unsigned long long int readCPUCycles() const; double durationToDouble( const Duration& duration ) const; TimePoint initialRealTime; Duration totalRealTime; double initialRealTime, totalRealTime, initialCPUTime, totalCPUTime; double initialCPUTime, totalCPUTime; unsigned long long int initialCPUCycles, totalCPUCycles; Loading @@ -127,7 +132,6 @@ class Timer } }; // !!! Odstranit ???!!! extern Timer defaultTimer; } // namespace TNL Loading
tnlConfig.h.in +0 −2 Original line number Diff line number Diff line @HAVE_SYS_TIME_H@ @HAVE_SYS_RESOURCE_H@ @HAVE_SYS_IOCTL_H@ Loading