mercurial/statprof.py
changeset 42423 0ae593e791fb
parent 41831 ae189674bdad
child 42833 3f81d58aae25
equal deleted inserted replaced
42422:381d8fa53f34 42423:0ae593e791fb
   676     root = HotNode(None)
   676     root = HotNode(None)
   677     lasttime = data.samples[0].time
   677     lasttime = data.samples[0].time
   678     for sample in data.samples:
   678     for sample in data.samples:
   679         root.add(sample.stack[::-1], sample.time - lasttime)
   679         root.add(sample.stack[::-1], sample.time - lasttime)
   680         lasttime = sample.time
   680         lasttime = sample.time
       
   681     showtime = kwargs.get(r'showtime', True)
   681 
   682 
   682     def _write(node, depth, multiple_siblings):
   683     def _write(node, depth, multiple_siblings):
   683         site = node.site
   684         site = node.site
   684         visiblechildren = [c for c in node.children.itervalues()
   685         visiblechildren = [c for c in node.children.itervalues()
   685                              if c.count >= (limit * root.count)]
   686                              if c.count >= (limit * root.count)]
   693                 function = childsite.function
   694                 function = childsite.function
   694 
   695 
   695             # lots of string formatting
   696             # lots of string formatting
   696             listpattern = ''.ljust(indent) +\
   697             listpattern = ''.ljust(indent) +\
   697                           ('\\' if multiple_siblings else '|') +\
   698                           ('\\' if multiple_siblings else '|') +\
   698                           ' %4.1f%%  %s %s'
   699                           ' %4.1f%%' +\
       
   700                           (' %5.2fs' % node.count if showtime else '') +\
       
   701                           '  %s %s'
   699             liststring = listpattern % (node.count / root.count * 100,
   702             liststring = listpattern % (node.count / root.count * 100,
   700                                         filename, function)
   703                                         filename, function)
   701             codepattern = '%' + ('%d' % (55 - len(liststring))) + 's %d:  %s'
   704             codepattern = '%' + ('%d' % (55 - len(liststring))) + 's %d:  %s'
   702             codestring = codepattern % ('line', site.lineno, site.getsource(30))
   705             codestring = codepattern % ('line', site.lineno, site.getsource(30))
   703 
   706