diff options
author | mdodd <mdodd@FreeBSD.org> | 2005-04-13 05:50:56 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2005-04-13 05:50:56 +0000 |
commit | 44f26591d0eb8d2b70851103e3fa6830826239bb (patch) | |
tree | 1480a3967e7f66514f011d6478d50882d6f198fd /tools | |
parent | 9a285e34ff2e1226c85e25c8f48f7752956f06a5 (diff) | |
download | FreeBSD-src-44f26591d0eb8d2b70851103e3fa6830826239bb.zip FreeBSD-src-44f26591d0eb8d2b70851103e3fa6830826239bb.tar.gz |
Add support for more than two datasets. Currently limited to 7 though
the limit is only the number of meaningful graph symbols available.
Statistical comparison is performed between the first dataset and
any further datasets.
No objection by: phk
Diffstat (limited to 'tools')
-rw-r--r-- | tools/tools/ministat/ministat.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/tools/tools/ministat/ministat.c b/tools/tools/ministat/ministat.c index dbe3cde..7c432f7 100644 --- a/tools/tools/ministat/ministat.c +++ b/tools/tools/ministat/ministat.c @@ -126,6 +126,9 @@ double student [NSTUDENT + 1][NCONF] = { /* 100. */ { 1.290, 1.660, 1.984, 2.364, 2.626, 3.174 } }; +#define MAX_DS 8 +static char symbol[MAX_DS] = { ' ', 'x', '+', '*', '%', '#', '@', 'O' }; + TAILQ_HEAD(pointlist, point); struct dataset { @@ -234,8 +237,7 @@ Vitals(struct dataset *ds, int flag) { double a; - printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", - flag == 1 ? 'x' : '+', + printf("%c %3d %13.8g %13.8g %13.8g %13.8g %13.8g", symbol[flag], ds->n, Min(ds), Max(ds), Median(ds), Avg(ds), Stddev(ds)); printf("\n"); } @@ -416,14 +418,10 @@ DumpPlot(void) putchar('|'); for (j = 0; j < pl->width; j++) { k = pl->data[(pl->height - i) * pl->width + j]; - switch (k) { - case 0: putchar(' '); break; - case 1: putchar('x'); break; - case 2: putchar('+'); break; - case 3: putchar('*'); break; - default: printf("[%02x]", k); break; - - } + if (k >= 0 && k < MAX_DS) + putchar(symbol[k]); + else + printf("[%02x]", k); } putchar('|'); putchar('\n'); @@ -503,7 +501,7 @@ usage(char const *whine) fprintf(stderr, "%s\n", whine); fprintf(stderr, - "Usage: ministat [ -c confidence ] [-s] [file 1 [file 2]]\n"); + "Usage: ministat [ -c confidence ] [-s] [file [file ...]]\n"); fprintf(stderr, "\tconfidence = {"); for (i = 0; i < NCONF; i++) { fprintf(stderr, "%s%g%%", @@ -518,7 +516,8 @@ usage(char const *whine) int main(int argc, char **argv) { - struct dataset *ds1, *ds2, *ds3; + struct dataset *ds[7]; + int nds; double a; char *p; int c, i, ci; @@ -550,29 +549,30 @@ main(int argc, char **argv) argv += optind; if (argc == 0) { - ds1 = ReadSet(NULL); + ds[0] = ReadSet(NULL); printf("x stdin\n"); - } else if (argc > 0) { - ds1 = ReadSet(argv[0]); - printf("x %s\n", argv[0]); - } if (argc > 1) { - ds2 = ReadSet(argv[1]); - printf("+ %s\n", argv[1]); + nds = 1; + } else { + if (argc > (MAX_DS - 1)) + usage("Too many datasets."); + nds = argc; + for (i = 0; i < nds; i++) { + ds[i] = ReadSet(argv[i]); + printf("%c %s\n", symbol[i+1], argv[i]); + } } SetupPlot(74, flag_s); - DimPlot(ds1); - if (argc > 1) - DimPlot(ds2); - PlotSet(ds1, 1); - if (argc > 1) - PlotSet(ds2, 2); + for (i = 0; i < nds; i++) + DimPlot(ds[i]); + for (i = 0; i < nds; i++) + PlotSet(ds[i], i + 1); DumpPlot(); VitalsHead(); - Vitals(ds1, 1); - if (argc > 1) { - Vitals(ds2, 2); - Relative(ds2, ds1, ci); + Vitals(ds[0], 1); + for (i = 1; i < nds; i++) { + Vitals(ds[i], i + 1); + Relative(ds[i], ds[0], ci); } exit(0); } |