revert support for monotonic clock - it is not faster than realtime

This commit is contained in:
gabime 2015-12-22 21:40:27 +02:00
parent e3c3f91c11
commit a1e25cdb28
2 changed files with 0 additions and 29 deletions

View File

@ -35,20 +35,6 @@ namespace details
namespace os
{
#if defined __linux__ && defined SPDLOG_CLOCK_MONOTONIC
inline uint64_t clock_offset()
{
timespec ts_realtime;
::clock_gettime(CLOCK_REALTIME, &ts_realtime);
timespec ts_monotonic;
::clock_gettime(CLOCK_MONOTONIC, &ts_monotonic);
const uint64_t realtime = ts_realtime.tv_sec * 1000000000 + ts_realtime.tv_nsec;
const uint64_t monotonic = ts_monotonic.tv_sec * 1000000000 + ts_monotonic.tv_nsec;
return realtime - monotonic;
}
#endif
inline spdlog::log_clock::time_point now()
{
@ -59,14 +45,7 @@ inline spdlog::log_clock::time_point now()
std::chrono::duration_cast<typename log_clock::duration>(
std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)));
#elif defined __linux__ && defined SPDLOG_CLOCK_MONOTONIC
static const auto offset = std::chrono::nanoseconds(clock_offset());
timespec ts;
::clock_gettime(CLOCK_MONOTONIC, &ts);
return std::chrono::time_point<log_clock, typename log_clock::duration>(
std::chrono::duration_cast<typename log_clock::duration>(
offset + std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec)));
#else
return log_clock::now();
#endif

View File

@ -17,14 +17,6 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Under Linux, the much faster CLOCK_MONOTONIC clock can be used.
// This clock is more accurate than CLOCK_REALTIME_COARSE and faster than regular clock.
// Uncomment to use it instead of the regular clock.
// #define SPDLOG_CLOCK_MONOTONIC
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment if date/time logging is not needed.
// This will prevent spdlog from quering the clock on each log call.