aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew N. Dodd <mdodd@FreeBSD.org>2005-04-13 05:50:56 +0000
committerMatthew N. Dodd <mdodd@FreeBSD.org>2005-04-13 05:50:56 +0000
commitafe98543b8fceba0a725b6758e48ad3867ea8ec3 (patch)
tree1480a3967e7f66514f011d6478d50882d6f198fd
parent014fbb87b87da169d523bc7c8a92de2001bb757f (diff)
downloadsrc-afe98543b8fceba0a725b6758e48ad3867ea8ec3.tar.gz
src-afe98543b8fceba0a725b6758e48ad3867ea8ec3.zip
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
Notes
Notes: svn path=/head/; revision=144993
-rw-r--r--tools/tools/ministat/ministat.c58
-rw-r--r--usr.bin/ministat/ministat.c58
2 files changed, 58 insertions, 58 deletions
diff --git a/tools/tools/ministat/ministat.c b/tools/tools/ministat/ministat.c
index dbe3cde6b501..7c432f7c9e3b 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);
}
diff --git a/usr.bin/ministat/ministat.c b/usr.bin/ministat/ministat.c
index dbe3cde6b501..7c432f7c9e3b 100644
--- a/usr.bin/ministat/ministat.c
+++ b/usr.bin/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);
}