mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added simple ASCII style histogram plot
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@226 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
112fbca28f
commit
310031dc16
4 changed files with 28 additions and 1 deletions
|
@ -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_ */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Add table
Reference in a new issue