示例#1
0
 def __print_query_times(self, data):
     """ print data to the user, expecting datetime keys and list(int) values """
     timings = perc.Stats([q[1] for q in self.queries])
     window = timings.percentile(25) - 1
     window2 = timings.percentile(50) - 1
     window3 = timings.percentile(75) - 1
     window4 = timings.percentile(99) - 1
     print(". <%sms + >%sms ! >%sms X >%sms" % (window, window2, window3, window4))
     print('-'*30)
     worst = None
     for time, qtimes in data:
         total = sum(qtimes)
         if not worst:
             worst = (time, total)
         elif total > worst[1]:
             worst = (time, total)
         print(time, ' ', end='')
         for qtime in qtimes:
             c = '.'
             if qtime > window2:
                 c = '+'
             if qtime > window3:
                 c = '!'
             if qtime > window4:
                 c = 'X'
             print(c, end='')
         print('')
     print('')
     print('worst period: %s (%sms)' % worst)
     print('')
示例#2
0
def get_percentiles(label,
                    data_list,
                    strformat="%.2f",
                    pmin=True,
                    pmax=True,
                    reverse=False,
                    percentiles=(99, 75, 50, 25)):
    """ gets formatted percentiles using numpy from data in a list """
    np_array = perc.Stats(data_list)
    printables = [label]
    if pmax:
        printables.append((strformat % np_array.max()))
    for p in percentiles:
        printables.append((strformat % np_array.percentile(p)))
    if pmin:
        printables.append((strformat % np_array.min()))
    if reverse:
        printables = list(reversed(printables))
    return printables
示例#3
0
def print_percentiles(label,
                      data_list,
                      indent=11,
                      width=8,
                      strformat="%.2f",
                      pmin=True,
                      pmax=True,
                      reverse=False,
                      percentiles=(99, 75, 50, 25)):
    """ prints formatted percentiles using numpy from data in a list """
    np_array = perc.Stats(data_list)
    printables = [label.ljust(indent)]
    if pmax:
        printables.append((strformat % np_array.max()).ljust(width))
    for p in percentiles:
        printables.append((strformat % np_array.percentile(p)).ljust(width))
    if pmin:
        printables.append((strformat % np_array.min()).ljust(width))
    if reverse:
        printables = reversed(printables)
    print("".join(printables))