Пример #1
0
def statcol(title, series, abbrev=''):
    'Returns a list of formatted statistics lines, usable in a column table.'
    statistics = lambda series: [('minimum', min(series)),
                                 ('median', median(series)),
                                 ('average', average(series)),
                                 ('maximum', max(series)),
                                 ('total', sum(series)),]

    col = [header(title),]
    for item in statistics(series):
        col.append(statline(*item, abbrev=abbrev))
    return col
Пример #2
0
def throughput(conn, credentials, command, abbrev=''):
    'Prints the 5min, 1hr, and 1day statistics for a given throughput.'
    ts = lambda seconds: timeseries(conn, credentials, seconds, command)

    mn5 = statcol('Last 5 Min', ts(300), abbrev)
    hr1 = statcol('Last Hour', ts(3600), abbrev)
    dy1 = statcol('Last Day', ts(86400), abbrev)

    rows = columnate([mn5, hr1, dy1])

    width = 0
    for row in rows:
        for line in row:
            width = max(width, c_len(line))
    print(header(command, width, ':'))
    print('')

    for row in rows:
        for line in row:
            print(line)
        print('')