Add a -q flag to ministat to suppress headers in output, for use with -n.

Reviewed by:	jrtc27
Differential Revision: https://reviews.freebsd.org/D33724
MFC after:	2 weeks
This commit is contained in:
Robert Watson 2021-12-18 20:02:08 +00:00
parent 1fbcaa13b0
commit 7776d3ccd1
2 changed files with 18 additions and 6 deletions

View file

@ -33,7 +33,7 @@
.Nd statistics utility
.Sh SYNOPSIS
.Nm
.Op Fl Ans
.Op Fl Anqs
.Op Fl C Ar column
.Op Fl c Ar confidence_level
.Op Fl d Ar delimiter
@ -53,6 +53,10 @@ suppress the ASCII-art plot.
.It Fl n
Just report the raw statistics of the input, suppress the ASCII-art plot
and the relative comparisons.
.It Fl q
Suppress printing of summary statistics and data-set names; typically for use
alongside
.Fl n .
.It Fl s
Print the average/median/stddev bars on separate lines in the ASCII-art
plot, to avoid overlap.

View file

@ -533,7 +533,7 @@ usage(char const *whine)
fprintf(stderr, "%s\n", whine);
fprintf(stderr,
"Usage: ministat [-C column] [-c confidence] [-d delimiter(s)] [-Ans] [-w width] [file [file ...]]\n");
"Usage: ministat [-C column] [-c confidence] [-d delimiter(s)] [-Anqs] [-w width] [file [file ...]]\n");
fprintf(stderr, "\tconfidence = {");
for (i = 0; i < NCONF; i++) {
fprintf(stderr, "%s%g%%",
@ -545,6 +545,7 @@ usage(char const *whine)
fprintf(stderr, "\t-C : column number to extract (starts and defaults to 1)\n");
fprintf(stderr, "\t-d : delimiter(s) string, default to \" \\t\"\n");
fprintf(stderr, "\t-n : print summary statistics only, no graph/test\n");
fprintf(stderr, "\t-q : suppress printing summary-statistics headers and data-set names\n");
fprintf(stderr, "\t-s : print avg/median/stddev bars on separate lines\n");
fprintf(stderr, "\t-w : width of graph/test output (default 74 or terminal width)\n");
exit (2);
@ -564,6 +565,7 @@ main(int argc, char **argv)
int column = 1;
int flag_s = 0;
int flag_n = 0;
int flag_q = 0;
int termwidth = 74;
int suppress_plot = 0;
@ -578,7 +580,7 @@ main(int argc, char **argv)
}
ci = -1;
while ((c = getopt(argc, argv, "AC:c:d:snw:")) != -1)
while ((c = getopt(argc, argv, "AC:c:d:snqw:")) != -1)
switch (c) {
case 'A':
suppress_plot = 1;
@ -608,6 +610,9 @@ main(int argc, char **argv)
case 'n':
flag_n = 1;
break;
case 'q':
flag_q = 1;
break;
case 's':
flag_s = 1;
break;
@ -664,8 +669,10 @@ main(int argc, char **argv)
fclose(setfiles[i]);
}
for (i = 0; i < nds; i++)
printf("%c %s\n", symbol[i+1], ds[i]->name);
if (!flag_q) {
for (i = 0; i < nds; i++)
printf("%c %s\n", symbol[i+1], ds[i]->name);
}
if (!flag_n && !suppress_plot) {
SetupPlot(termwidth, flag_s, nds);
@ -675,7 +682,8 @@ main(int argc, char **argv)
PlotSet(ds[i], i + 1);
DumpPlot();
}
VitalsHead();
if (!flag_q)
VitalsHead();
Vitals(ds[0], 1);
for (i = 1; i < nds; i++) {
Vitals(ds[i], i + 1);