Commit cd3e853f authored by Joanne Hugé's avatar Joanne Hugé

WIP

parent d1146ff6
......@@ -13,7 +13,7 @@
#include "tracer.h"
#define CLOCK_ID CLOCK_MONOTONIC
#define NSEC_PER_SEC INT64_C(1000000000)
#define NSEC_PER_SEC UINT64_C(1000000000)
typedef struct thread_stat {
int nb_cycles;
......@@ -60,32 +60,32 @@ static void *timerthread(void *p) {
stat->max_res = 0;
stat->min_res = UINT64_MAX;
if(param->enable_tracing)
tracing(1);
if (param->enable_tracing) tracing(1);
for (stat->nb_cycles = 0;; stat->nb_cycles++) {
if (param->max_cycles && (stat->nb_cycles >= param->max_cycles)) break;
if(param->enable_tracing)
tracemark("Time measure start\n");
if (param->enable_tracing) tracemark("Time measure start\n");
clock_gettime(CLOCK_ID, &previous);
clock_gettime(CLOCK_ID, &current);
if(param->enable_tracing)
tracemark("Time measure end");
if (param->enable_tracing) tracemark("Time measure end");
diff = calcdiff_ns(current, previous);
sprintf(time_measured_string, "Diff measured: %" PRIu64 "\n", diff);
sprintf(time_measured_string,
"Diff measured: %" PRIu64
", Current (%ld, %ld), Previous (%ld, %ld)\n",
diff, current.tv_sec, current.tv_nsec, previous.tv_sec,
previous.tv_nsec);
if (param->enable_tracing) tracemark(time_measured_string);
if(param->enable_tracing)
tracemark(time_measured_string);
stat->max_res = max(stat->max_res, diff);
stat->min_res = min(stat->min_res, diff);
if( param->enable_tracing && (diff > param->latency_threshold) ) {
if (param->enable_tracing && (diff > param->latency_threshold)) {
tracing(0);
break;
}
......@@ -93,9 +93,7 @@ static void *timerthread(void *p) {
usleep(param->interval);
}
if(param->enable_tracing)
tracing(0);
if (param->enable_tracing) tracing(0);
return NULL;
}
......@@ -117,7 +115,7 @@ int main(int argc, char *argv[]) {
process_options(argc, argv, &param, &main_param);
if(main_param.enable_tracing) {
if (main_param.enable_tracing) {
param.enable_tracing = 1;
setup_tracer();
}
......@@ -136,12 +134,13 @@ int main(int argc, char *argv[]) {
param.stat.nb_cycles);
if (param.max_cycles == param.stat.nb_cycles) break;
if (main_param.enable_tracing && (param.stat.max_res >= param.latency_threshold)) break;
if (main_param.enable_tracing &&
(param.stat.max_res >= param.latency_threshold))
break;
}
// Just in case main exists before the thread
if(main_param.enable_tracing)
tracing(0);
if (main_param.enable_tracing) tracing(0);
exit(EXIT_SUCCESS);
}
......
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