def worstblocks_topten(t, n=10): from pypy.tool.ansi_print import ansi_print ann = t.annotator h = [(count, block) for block, count in ann.reflowcounter.iteritems()] h.sort() if not h: print "annotator should have been run with debug collecting enabled" return print ansi_print(',----------------------- Top %d Most Reflown Blocks -----------------------.' % n, 36) for i in range(n): if not h: break count, block = h.pop() ansi_print(' #%3d: reflown %d times |' % (i+1, count), 36) t.about(block) ansi_print("`----------------------------------------------------------------------------'", 36) print
def debug_print(text, file=None, newline=True): # 31: ANSI color code "red" ansi_print(text, esc="31", file=file, newline=newline)