mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
remove custom timestamp stuff from logger wrapper
This commit is contained in:
parent
a3393e600e
commit
a91c481abf
|
@ -503,19 +503,19 @@ void FairMQDevice::RunWrapper()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using Clock = std::chrono::steady_clock;
|
using Clock = chrono::steady_clock;
|
||||||
using TimeScale = std::chrono::microseconds;
|
using TimeScale = chrono::microseconds;
|
||||||
const TimeScale::rep period = TimeScale::period::den / fRate;
|
const TimeScale::rep period = TimeScale::period::den / fRate;
|
||||||
const auto reftime = Clock::now();
|
const auto reftime = Clock::now();
|
||||||
while (CheckCurrentState(RUNNING) && ConditionalRun())
|
while (CheckCurrentState(RUNNING) && ConditionalRun())
|
||||||
{
|
{
|
||||||
if (fRate > 0.001) {
|
if (fRate > 0.001) {
|
||||||
auto timespan = std::chrono::duration_cast<TimeScale>(Clock::now() - reftime).count() - fLastTime;
|
auto timespan = chrono::duration_cast<TimeScale>(Clock::now() - reftime).count() - fLastTime;
|
||||||
if (timespan < period) {
|
if (timespan < period) {
|
||||||
TimeScale sleepfor(period - timespan);
|
TimeScale sleepfor(period - timespan);
|
||||||
std::this_thread::sleep_for(sleepfor);
|
this_thread::sleep_for(sleepfor);
|
||||||
}
|
}
|
||||||
fLastTime = std::chrono::duration_cast<TimeScale>(Clock::now() - reftime).count();
|
fLastTime = chrono::duration_cast<TimeScale>(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.";
|
LOG(error) << "FairMQDevice::PollForTransport() failed: " << e.what() << ", going to ERROR state.";
|
||||||
ChangeState(ERROR_FOUND);
|
ChangeState(ERROR_FOUND);
|
||||||
|
@ -903,10 +903,10 @@ void FairMQDevice::SetConfig(FairMQProgOptions& config)
|
||||||
|
|
||||||
void FairMQDevice::LogSocketRates()
|
void FairMQDevice::LogSocketRates()
|
||||||
{
|
{
|
||||||
timestamp_t t0;
|
chrono::time_point<chrono::high_resolution_clock> t0;
|
||||||
timestamp_t t1;
|
chrono::time_point<chrono::high_resolution_clock> t1;
|
||||||
|
|
||||||
timestamp_t msSinceLastLog;
|
unsigned long long msSinceLastLog;
|
||||||
|
|
||||||
vector<FairMQSocket*> filteredSockets;
|
vector<FairMQSocket*> filteredSockets;
|
||||||
vector<string> filteredChannelNames;
|
vector<string> filteredChannelNames;
|
||||||
|
@ -958,15 +958,15 @@ void FairMQDevice::LogSocketRates()
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
t0 = get_timestamp();
|
t0 = chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
LOG(debug) << "<channel>: in: <#msgs> (<MB>) out: <#msgs> (<MB>)";
|
LOG(debug) << "<channel>: in: <#msgs> (<MB>) out: <#msgs> (<MB>)";
|
||||||
|
|
||||||
while (CheckCurrentState(RUNNING))
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
t1 = get_timestamp();
|
t1 = chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
msSinceLastLog = (t1 - t0) / 1000.0L;
|
msSinceLastLog = chrono::duration_cast<chrono::milliseconds>(t1 - t0).count();
|
||||||
|
|
||||||
i = 0;
|
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);
|
return fChannels.at(channelName).at(index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,3 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
timestamp_t get_timestamp()
|
|
||||||
{
|
|
||||||
struct timeval now;
|
|
||||||
gettimeofday(&now, nullptr);
|
|
||||||
return now.tv_usec + static_cast<timestamp_t>(now.tv_sec) * 1000000;
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,8 +17,4 @@
|
||||||
|
|
||||||
#include <Logger.h>
|
#include <Logger.h>
|
||||||
|
|
||||||
using timestamp_t = unsigned long long;
|
|
||||||
|
|
||||||
timestamp_t get_timestamp();
|
|
||||||
|
|
||||||
#endif /* FAIRMQLOGGER_H_ */
|
#endif /* FAIRMQLOGGER_H_ */
|
||||||
|
|
|
@ -188,18 +188,18 @@ void FairMQShmPrototypeSampler::Run()
|
||||||
|
|
||||||
void FairMQShmPrototypeSampler::Log(const int intervalInMs)
|
void FairMQShmPrototypeSampler::Log(const int intervalInMs)
|
||||||
{
|
{
|
||||||
timestamp_t t0 = get_timestamp();
|
chrono::time_point<chrono::high_resolution_clock> t0 = chrono::high_resolution_clock::now();
|
||||||
timestamp_t t1;
|
chrono::time_point<chrono::high_resolution_clock> t1;
|
||||||
timestamp_t msSinceLastLog;
|
unsigned long long msSinceLastLog;
|
||||||
|
|
||||||
double mbPerSecOut = 0;
|
double mbPerSecOut = 0;
|
||||||
double msgPerSecOut = 0;
|
double msgPerSecOut = 0;
|
||||||
|
|
||||||
while (CheckCurrentState(RUNNING))
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
t1 = get_timestamp();
|
t1 = chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
msSinceLastLog = (t1 - t0) / 1000.0L;
|
msSinceLastLog = chrono::duration_cast<chrono::milliseconds>(t1 - t0).count();
|
||||||
|
|
||||||
mbPerSecOut = (static_cast<double>(fBytesOutNew - fBytesOut) / (1024. * 1024.)) / static_cast<double>(msSinceLastLog) * 1000.;
|
mbPerSecOut = (static_cast<double>(fBytesOutNew - fBytesOut) / (1024. * 1024.)) / static_cast<double>(msSinceLastLog) * 1000.;
|
||||||
fBytesOut = fBytesOutNew;
|
fBytesOut = fBytesOutNew;
|
||||||
|
|
|
@ -115,18 +115,18 @@ void FairMQShmPrototypeSink::Run()
|
||||||
|
|
||||||
void FairMQShmPrototypeSink::Log(const int intervalInMs)
|
void FairMQShmPrototypeSink::Log(const int intervalInMs)
|
||||||
{
|
{
|
||||||
timestamp_t t0 = get_timestamp();
|
chrono::time_point<chrono::high_resolution_clock> t0 = chrono::high_resolution_clock::now();
|
||||||
timestamp_t t1;
|
chrono::time_point<chrono::high_resolution_clock> t1;
|
||||||
timestamp_t msSinceLastLog;
|
unsigned long long msSinceLastLog;
|
||||||
|
|
||||||
double mbPerSecIn = 0;
|
double mbPerSecIn = 0;
|
||||||
double msgPerSecIn = 0;
|
double msgPerSecIn = 0;
|
||||||
|
|
||||||
while (CheckCurrentState(RUNNING))
|
while (CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
t1 = get_timestamp();
|
t1 = chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
msSinceLastLog = (t1 - t0) / 1000.0L;
|
msSinceLastLog = chrono::duration_cast<chrono::milliseconds>(t1 - t0).count();
|
||||||
|
|
||||||
mbPerSecIn = (static_cast<double>(fBytesInNew - fBytesIn) / (1024. * 1024.)) / static_cast<double>(msSinceLastLog) * 1000.;
|
mbPerSecIn = (static_cast<double>(fBytesInNew - fBytesIn) / (1024. * 1024.)) / static_cast<double>(msSinceLastLog) * 1000.;
|
||||||
fBytesIn = fBytesInNew;
|
fBytesIn = fBytesInNew;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user