diff --git a/server/include/config.h b/server/include/config.h index 4814e8b74..4b81f4bfa 100644 --- a/server/include/config.h +++ b/server/include/config.h @@ -21,6 +21,7 @@ #define SOCKET_PRIO 7 /* Some parameters for histogram statistics */ -#define HIST_SEQ 33 +#define HIST_HEIGHT 50 +#define HIST_SEQ 17 #endif /* _CONFIG_H_ */ diff --git a/server/include/utils.h b/server/include/utils.h index 8225363f4..681cb5efd 100644 --- a/server/include/utils.h +++ b/server/include/utils.h @@ -70,6 +70,9 @@ double timespec_delta(struct timespec *start, struct timespec *end); /** Get period as timespec from rate */ struct timespec timespec_rate(double rate); +/** Print ASCII style plot of histogram */ +void hist_print(unsigned *hist, int length); + /** Dump histogram data in Matlab format */ void hist_dump(unsigned *hist, int length); diff --git a/server/src/path.c b/server/src/path.c index 0da8868be..e94bb8cb5 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -149,6 +149,7 @@ int path_stop(struct path *p) if (p->received) { path_stats(p); + hist_print(p->histogram, HIST_SEQ); hist_dump(p->histogram, HIST_SEQ); } diff --git a/server/src/utils.c b/server/src/utils.c index 8784977d0..32bfa498e 100644 --- a/server/src/utils.c +++ b/server/src/utils.c @@ -122,6 +122,28 @@ struct timespec timespec_rate(double rate) return ts; } +void hist_print(unsigned *hist, int length) +{ + char buf[HIST_HEIGHT + 8]; + int max = 0; + + /* Get max */ + for (int i = 0; i < length; i++) { + if (hist[i] > hist[max]) + max = i; + + } + + /* Print plot */ + for (int i = 0; i < length; i++) { + memset(buf, 0, sizeof(buf)); + for (int j = 0; j < HIST_HEIGHT * (float) hist[i] / hist[max]; j++) + strcat(buf, "#"); + + info("%2u: %s", i, buf); + } +} + void hist_dump(unsigned *hist, int length) { char tok[16];