Commit ce73ba1c authored by Valentin Reis's avatar Valentin Reis

Using CLOCK_MONOTONIC

parent b46302e2
Pipeline #4555 failed with stages
in 3 seconds
...@@ -36,7 +36,7 @@ int nrm_init(struct nrm_context *ctxt, const char *uuid) ...@@ -36,7 +36,7 @@ int nrm_init(struct nrm_context *ctxt, const char *uuid)
sleep(1); sleep(1);
err = zmq_send(ctxt->socket, buf, strnlen(buf, 512), 0); err = zmq_send(ctxt->socket, buf, strnlen(buf, 512), 0);
assert(err > 0); assert(err > 0);
assert(!clock_gettime(CLOCK_REALTIME, &ctxt->time)); assert(!clock_gettime(CLOCK_MONOTONIC, &ctxt->time));
ctxt->acc = 0; ctxt->acc = 0;
return 0; return 0;
} }
...@@ -57,11 +57,11 @@ int nrm_send_progress(struct nrm_context *ctxt, unsigned long progress) ...@@ -57,11 +57,11 @@ int nrm_send_progress(struct nrm_context *ctxt, unsigned long progress)
{ {
char buf[512]; char buf[512];
struct timespec now; struct timespec now;
clock_gettime(CLOCK_REALTIME, &now); clock_gettime(CLOCK_MONOTONIC, &now);
long long int timediff = (now.tv_nsec - ctxt->time.tv_nsec) + long long int timediff = (now.tv_nsec - ctxt->time.tv_nsec) +
1e9* (now.tv_sec - ctxt->time.tv_sec); 1e9* (now.tv_sec - ctxt->time.tv_sec);
ctxt->acc += progress; ctxt->acc += progress;
if(timediff > NRM_RATELIMIT_THRESHOLD) if(timediff > NRM_RATELIMIT_THRESHOLD)
{ {
snprintf(buf, 512, NRM_PROGRESS_FORMAT, ctxt->acc, ctxt->app_uuid); snprintf(buf, 512, NRM_PROGRESS_FORMAT, ctxt->acc, ctxt->app_uuid);
int err = zmq_send(ctxt->socket, buf, strnlen(buf, 512), 0); int err = zmq_send(ctxt->socket, buf, strnlen(buf, 512), 0);
...@@ -78,11 +78,11 @@ int nrm_send_phase_context(struct nrm_context *ctxt, unsigned int cpu, unsigned ...@@ -78,11 +78,11 @@ int nrm_send_phase_context(struct nrm_context *ctxt, unsigned int cpu, unsigned
{ {
char buf[512]; char buf[512];
struct timespec now; struct timespec now;
clock_gettime(CLOCK_REALTIME, &now); clock_gettime(CLOCK_MONOTONIC, &now);
long long int timediff = (now.tv_nsec - ctxt->time.tv_nsec) + long long int timediff = (now.tv_nsec - ctxt->time.tv_nsec) +
1e9* (now.tv_sec - ctxt->time.tv_sec); 1e9* (now.tv_sec - ctxt->time.tv_sec);
if(timediff > NRM_RATELIMIT_THRESHOLD) if(timediff > NRM_RATELIMIT_THRESHOLD)
{ {
snprintf(buf, 512, NRM_PHASE_CONTEXT_FORMAT, cpu, aggregation, snprintf(buf, 512, NRM_PHASE_CONTEXT_FORMAT, cpu, aggregation,
computeTime, totalTime, ctxt->app_uuid); computeTime, totalTime, ctxt->app_uuid);
...@@ -90,5 +90,5 @@ int nrm_send_phase_context(struct nrm_context *ctxt, unsigned int cpu, unsigned ...@@ -90,5 +90,5 @@ int nrm_send_phase_context(struct nrm_context *ctxt, unsigned int cpu, unsigned
assert(err > 0); assert(err > 0);
} }
ctxt->time = now; ctxt->time = now;
return 0; return 0;
} }
...@@ -50,7 +50,7 @@ int nrm_send_phase_context(struct nrm_context *ctxt, ...@@ -50,7 +50,7 @@ int nrm_send_phase_context(struct nrm_context *ctxt,
inline long long int nrm_gettime(void) inline long long int nrm_gettime(void)
{ {
struct timespec now; struct timespec now;
clock_gettime(CLOCK_REALTIME, &now); clock_gettime(CLOCK_MONOTONIC, &now);
return ((now.tv_sec * 1e9) + now.tv_nsec); return ((now.tv_sec * 1e9) + now.tv_nsec);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment