changeset 16263:be92ddc636e3

profile: add undocumented config options for profiler output
author Matt Mackall <mpm@selenic.com>
date Thu, 15 Mar 2012 15:59:26 -0500
parents bf7a6c3b2a4a
children 77d56a5e74a5
files mercurial/dispatch.py mercurial/lsprof.py
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Thu Mar 15 15:58:55 2012 -0500
+++ b/mercurial/dispatch.py	Thu Mar 15 15:59:26 2012 -0500
@@ -694,6 +694,8 @@
 
     if options['profile']:
         format = ui.config('profiling', 'format', default='text')
+        field = ui.config('profiling', 'sort', default='inlinetime')
+        climit = ui.configint('profiling', 'nested', default=5)
 
         if not format in ['text', 'kcachegrind']:
             ui.warn(_("unrecognized profiling format '%s'"
@@ -728,8 +730,8 @@
             else:
                 # format == 'text'
                 stats = lsprof.Stats(p.getstats())
-                stats.sort()
-                stats.pprint(top=10, file=ostream, climit=5)
+                stats.sort(field)
+                stats.pprint(limit=30, file=ostream, climit=climit)
 
             if output:
                 ostream.close()
--- a/mercurial/lsprof.py	Thu Mar 15 15:58:55 2012 -0500
+++ b/mercurial/lsprof.py	Thu Mar 15 15:59:26 2012 -0500
@@ -48,7 +48,7 @@
             if limit is not None and count == limit:
                 return
             ccount = 0
-            if e.calls:
+            if climit and e.calls:
                 for se in e.calls:
                     file.write(cols % ("+%s" % se.callcount, se.reccallcount,
                                        se.totaltime, se.inlinetime,