Index: usr.bin/ministat/ministat.1 =================================================================== --- usr.bin/ministat/ministat.1 +++ usr.bin/ministat/ministat.1 @@ -1,5 +1,6 @@ .\" .\" Copyright (c) 2007 Poul-Henning Kamp +.\" Copyright 2015 Netflix, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 10, 2012 +.Dd July 4, 2015 .Dt MINISTAT 1 .Os .Sh NAME @@ -33,7 +34,7 @@ .Nd statistics utility .Sh SYNOPSIS .Nm -.Op Fl Ans +.Op Fl Ains .Op Fl C Ar column .Op Fl c Ar confidence_level .Op Fl d Ar delimiter @@ -50,6 +51,10 @@ .It Fl A Just report the statistics of the input and relative comparisons, suppress the ASCII-art plot. +.It Fl i +All values are inverted (1/x) when they are added. +This is useful for turning a set of times (seconds) into per seconds +(aka throughput). .It Fl n Just report the raw statistics of the input, suppress the ASCII-art plot and the relative comparisons. Index: usr.bin/ministat/ministat.c =================================================================== --- usr.bin/ministat/ministat.c +++ usr.bin/ministat/ministat.c @@ -447,7 +447,7 @@ } static struct dataset * -ReadSet(const char *n, int column, const char *delim) +ReadSet(const char *n, int column, const char *delim, int invert) { FILE *f; char buf[BUFSIZ], *p, *t; @@ -488,8 +488,11 @@ d = strtod(t, &p); if (p != NULL && *p != '\0') err(2, "Invalid data on line %d in %s\n", line, n); - if (*buf != '\0') + if (*buf != '\0') { + if (invert) + d = 1 / d; AddPoint(s, d); + } } fclose(f); if (s->n < 3) { @@ -508,7 +511,7 @@ 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)] [-Ains] [-w width] [file [file ...]]\n"); fprintf(stderr, "\tconfidence = {"); for (i = 0; i < NCONF; i++) { fprintf(stderr, "%s%g%%", @@ -519,6 +522,7 @@ fprintf(stderr, "\t-A : print statistics only. suppress the graph.\n"); 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-i : invert data, all data will be 1/x\n"); fprintf(stderr, "\t-n : print summary statistics only, no graph/test\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"); @@ -535,8 +539,9 @@ char *p; int c, i, ci; int column = 1; - int flag_s = 0; + int flag_i = 0; int flag_n = 0; + int flag_s = 0; int termwidth = 74; int suppress_plot = 0; @@ -551,7 +556,7 @@ } ci = -1; - while ((c = getopt(argc, argv, "AC:c:d:snw:")) != -1) + while ((c = getopt(argc, argv, "AC:c:d:insw:")) != -1) switch (c) { case 'A': suppress_plot = 1; @@ -578,6 +583,9 @@ usage("Can't use empty delimiter string"); delim = optarg; break; + case 'i': + flag_i = 1; + break; case 'n': flag_n = 1; break; @@ -601,14 +609,14 @@ argv += optind; if (argc == 0) { - ds[0] = ReadSet("-", column, delim); + ds[0] = ReadSet("-", column, delim, flag_i); 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], column, delim); + ds[i] = ReadSet(argv[i], column, delim, flag_i); } for (i = 0; i < nds; i++)