comparison mercurial/dispatch.py @ 8024:9a1b86cfd29e

profiling: Adding support for kcachegrind output format, using lsprofcalltree
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Wed, 08 Apr 2009 14:20:57 +0200
parents fd9debb3ea1b
children 6b5522cb2ad2
comparison
equal deleted inserted replaced
8023:fd9debb3ea1b 8024:9a1b86cfd29e
379 raise error.ParseError(cmd, _("invalid arguments")) 379 raise error.ParseError(cmd, _("invalid arguments"))
380 380
381 if options['profile']: 381 if options['profile']:
382 format = ui.config('profiling', 'format', default='text') 382 format = ui.config('profiling', 'format', default='text')
383 383
384 if not format in ['text']: 384 if not format in ['text', 'kcachegrind']:
385 ui.warn(_("unrecognized profiling format '%s'" 385 ui.warn(_("unrecognized profiling format '%s'"
386 " - Ignored\n") % format) 386 " - Ignored\n") % format)
387 format = 'text' 387 format = 'text'
388 388
389 output = ui.config('profiling', 'output') 389 output = ui.config('profiling', 'output')
405 p.enable(subcalls=True) 405 p.enable(subcalls=True)
406 try: 406 try:
407 return checkargs() 407 return checkargs()
408 finally: 408 finally:
409 p.disable() 409 p.disable()
410 stats = lsprof.Stats(p.getstats()) 410
411 stats.sort() 411 if format == 'kcachegrind':
412 stats.pprint(top=10, file=ostream, climit=5) 412 import lsprofcalltree
413 calltree = lsprofcalltree.KCacheGrind(p)
414 calltree.output(ostream)
415 else:
416 # format == 'text'
417 stats = lsprof.Stats(p.getstats())
418 stats.sort()
419 stats.pprint(top=10, file=ostream, climit=5)
413 420
414 if output: 421 if output:
415 ostream.close() 422 ostream.close()
416 else: 423 else:
417 return checkargs() 424 return checkargs()