diff --git a/fairmq/FairMQDevice.cxx b/fairmq/FairMQDevice.cxx index acd1e48d..85720706 100644 --- a/fairmq/FairMQDevice.cxx +++ b/fairmq/FairMQDevice.cxx @@ -503,19 +503,19 @@ void FairMQDevice::RunWrapper() } else { - using Clock = std::chrono::steady_clock; - using TimeScale = std::chrono::microseconds; + using Clock = chrono::steady_clock; + using TimeScale = chrono::microseconds; const TimeScale::rep period = TimeScale::period::den / fRate; const auto reftime = Clock::now(); while (CheckCurrentState(RUNNING) && ConditionalRun()) { if (fRate > 0.001) { - auto timespan = std::chrono::duration_cast(Clock::now() - reftime).count() - fLastTime; + auto timespan = chrono::duration_cast(Clock::now() - reftime).count() - fLastTime; if (timespan < period) { TimeScale sleepfor(period - timespan); - std::this_thread::sleep_for(sleepfor); + this_thread::sleep_for(sleepfor); } - fLastTime = std::chrono::duration_cast(Clock::now() - reftime).count(); + fLastTime = chrono::duration_cast(Clock::now() - reftime).count(); } } @@ -701,7 +701,7 @@ void FairMQDevice::PollForTransport(const FairMQTransportFactory* factory, const } } } - catch (std::exception& e) + catch (exception& e) { LOG(error) << "FairMQDevice::PollForTransport() failed: " << e.what() << ", going to ERROR state."; ChangeState(ERROR_FOUND); @@ -903,10 +903,10 @@ void FairMQDevice::SetConfig(FairMQProgOptions& config) void FairMQDevice::LogSocketRates() { - timestamp_t t0; - timestamp_t t1; + chrono::time_point t0; + chrono::time_point t1; - timestamp_t msSinceLastLog; + unsigned long long msSinceLastLog; vector filteredSockets; vector filteredChannelNames; @@ -958,15 +958,15 @@ void FairMQDevice::LogSocketRates() ++i; } - t0 = get_timestamp(); + t0 = chrono::high_resolution_clock::now(); LOG(debug) << ": in: <#msgs> () out: <#msgs> ()"; while (CheckCurrentState(RUNNING)) { - t1 = get_timestamp(); + t1 = chrono::high_resolution_clock::now(); - msSinceLastLog = (t1 - t0) / 1000.0L; + msSinceLastLog = chrono::duration_cast(t1 - t0).count(); i = 0; @@ -1056,7 +1056,7 @@ void FairMQDevice::Reset() } } -const FairMQChannel& FairMQDevice::GetChannel(const std::string& channelName, const int index) const +const FairMQChannel& FairMQDevice::GetChannel(const string& channelName, const int index) const { return fChannels.at(channelName).at(index); } diff --git a/fairmq/FairMQLogger.cxx b/fairmq/FairMQLogger.cxx index ad652b54..a4cb7409 100644 --- a/fairmq/FairMQLogger.cxx +++ b/fairmq/FairMQLogger.cxx @@ -13,13 +13,3 @@ */ #include "FairMQLogger.h" - -#include -#include - -timestamp_t get_timestamp() -{ - struct timeval now; - gettimeofday(&now, nullptr); - return now.tv_usec + static_cast(now.tv_sec) * 1000000; -} diff --git a/fairmq/FairMQLogger.h b/fairmq/FairMQLogger.h index d76fbdd2..95775df3 100644 --- a/fairmq/FairMQLogger.h +++ b/fairmq/FairMQLogger.h @@ -17,8 +17,4 @@ #include -using timestamp_t = unsigned long long; - -timestamp_t get_timestamp(); - #endif /* FAIRMQLOGGER_H_ */ diff --git a/fairmq/shmem/prototype/FairMQShmPrototypeSampler.cxx b/fairmq/shmem/prototype/FairMQShmPrototypeSampler.cxx index ebfb1400..bff66f5d 100644 --- a/fairmq/shmem/prototype/FairMQShmPrototypeSampler.cxx +++ b/fairmq/shmem/prototype/FairMQShmPrototypeSampler.cxx @@ -188,18 +188,18 @@ void FairMQShmPrototypeSampler::Run() void FairMQShmPrototypeSampler::Log(const int intervalInMs) { - timestamp_t t0 = get_timestamp(); - timestamp_t t1; - timestamp_t msSinceLastLog; + chrono::time_point t0 = chrono::high_resolution_clock::now(); + chrono::time_point t1; + unsigned long long msSinceLastLog; double mbPerSecOut = 0; double msgPerSecOut = 0; while (CheckCurrentState(RUNNING)) { - t1 = get_timestamp(); + t1 = chrono::high_resolution_clock::now(); - msSinceLastLog = (t1 - t0) / 1000.0L; + msSinceLastLog = chrono::duration_cast(t1 - t0).count(); mbPerSecOut = (static_cast(fBytesOutNew - fBytesOut) / (1024. * 1024.)) / static_cast(msSinceLastLog) * 1000.; fBytesOut = fBytesOutNew; diff --git a/fairmq/shmem/prototype/FairMQShmPrototypeSink.cxx b/fairmq/shmem/prototype/FairMQShmPrototypeSink.cxx index 941f1f7b..bbf8ca7d 100644 --- a/fairmq/shmem/prototype/FairMQShmPrototypeSink.cxx +++ b/fairmq/shmem/prototype/FairMQShmPrototypeSink.cxx @@ -115,18 +115,18 @@ void FairMQShmPrototypeSink::Run() void FairMQShmPrototypeSink::Log(const int intervalInMs) { - timestamp_t t0 = get_timestamp(); - timestamp_t t1; - timestamp_t msSinceLastLog; + chrono::time_point t0 = chrono::high_resolution_clock::now(); + chrono::time_point t1; + unsigned long long msSinceLastLog; double mbPerSecIn = 0; double msgPerSecIn = 0; while (CheckCurrentState(RUNNING)) { - t1 = get_timestamp(); + t1 = chrono::high_resolution_clock::now(); - msSinceLastLog = (t1 - t0) / 1000.0L; + msSinceLastLog = chrono::duration_cast(t1 - t0).count(); mbPerSecIn = (static_cast(fBytesInNew - fBytesIn) / (1024. * 1024.)) / static_cast(msSinceLastLog) * 1000.; fBytesIn = fBytesInNew;