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

Making tracing optional

parent a7d3c837
...@@ -24,6 +24,7 @@ typedef struct thread_stat { ...@@ -24,6 +24,7 @@ typedef struct thread_stat {
typedef struct thread_param { typedef struct thread_param {
int priority; int priority;
int max_cycles; int max_cycles;
int enable_tracing;
uint64_t interval; uint64_t interval;
uint64_t latency_threshold; uint64_t latency_threshold;
thread_stat_t stat; thread_stat_t stat;
...@@ -31,6 +32,7 @@ typedef struct thread_param { ...@@ -31,6 +32,7 @@ typedef struct thread_param {
typedef struct main_param { typedef struct main_param {
int refresh_rate; int refresh_rate;
int enable_tracing;
} main_param_t; } main_param_t;
static void process_options(int argc, char *argv[], thread_param_t *param, static void process_options(int argc, char *argv[], thread_param_t *param,
...@@ -60,17 +62,21 @@ static void *timerthread(void *p) { ...@@ -60,17 +62,21 @@ static void *timerthread(void *p) {
for (stat->nb_cycles = 0;; stat->nb_cycles++) { for (stat->nb_cycles = 0;; stat->nb_cycles++) {
if (param->max_cycles && (stat->nb_cycles >= param->max_cycles)) break; if (param->max_cycles && (stat->nb_cycles >= param->max_cycles)) break;
tracing(1); if(param->enable_tracing)
tracing(1);
clock_gettime(CLOCK_ID, &previous); clock_gettime(CLOCK_ID, &previous);
clock_gettime(CLOCK_ID, &current); clock_gettime(CLOCK_ID, &current);
tracing(0);
if(param->enable_tracing)
tracing(0);
diff = calcdiff_ns(current, previous); diff = calcdiff_ns(current, previous);
stat->max_res = max(stat->max_res, diff); stat->max_res = max(stat->max_res, diff);
stat->min_res = min(stat->min_res, diff); stat->min_res = min(stat->min_res, diff);
if( diff > param->latency_threshold ) break; if( param->enable_tracing && (diff > param->latency_threshold) ) break;
usleep(param->interval); usleep(param->interval);
} }
...@@ -89,10 +95,16 @@ int main(int argc, char *argv[]) { ...@@ -89,10 +95,16 @@ int main(int argc, char *argv[]) {
param.interval = 1000; param.interval = 1000;
param.max_cycles = 100000; param.max_cycles = 100000;
param.priority = 99; param.priority = 99;
param.enable_tracing = 0;
main_param.enable_tracing = 0;
main_param.refresh_rate = 10000; main_param.refresh_rate = 10000;
process_options(argc, argv, &param, &main_param); process_options(argc, argv, &param, &main_param);
setup_tracer();
if(main_param.enable_tracing) {
param.enable_tracing = 1;
setup_tracer();
}
usleep(10000); usleep(10000);
...@@ -108,7 +120,7 @@ int main(int argc, char *argv[]) { ...@@ -108,7 +120,7 @@ int main(int argc, char *argv[]) {
param.stat.nb_cycles); param.stat.nb_cycles);
if (param.max_cycles == param.stat.nb_cycles) break; if (param.max_cycles == param.stat.nb_cycles) break;
if (param.stat.max_res >= param.latency_threshold) break; if (main_param.enable_tracing && (param.stat.max_res >= param.latency_threshold)) break;
} }
tracing(0); tracing(0);
...@@ -119,7 +131,7 @@ int main(int argc, char *argv[]) { ...@@ -119,7 +131,7 @@ int main(int argc, char *argv[]) {
static void process_options(int argc, char *argv[], thread_param_t *param, static void process_options(int argc, char *argv[], thread_param_t *param,
main_param_t *main_param) { main_param_t *main_param) {
for (;;) { for (;;) {
int c = getopt(argc, argv, "l:p:i:r:b:"); int c = getopt(argc, argv, "l:p:i:r:b:f:");
if (c == -1) break; if (c == -1) break;
...@@ -139,6 +151,9 @@ static void process_options(int argc, char *argv[], thread_param_t *param, ...@@ -139,6 +151,9 @@ static void process_options(int argc, char *argv[], thread_param_t *param,
case 'r': case 'r':
main_param->refresh_rate = atoi(optarg); main_param->refresh_rate = atoi(optarg);
break; break;
case 'f':
main_param->enable_tracing = 1;
break;
default: default:
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
break; break;
......
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