changeset 32851:cb6436e051ca

profiling: allow configuring minimum display threshold for hotpath statprof.display_hotpath() accepts a "limit" function to choose the minimum threshold for samples to display. The default is 0.05, which means you don't need individual items contributing less than 5%. I had a need to adjust this threshold. We already have a config option for it. So let's reuse it. check-config.py doesn't like having multiple defaults for the ui.configwith() calls. The behavior is obviously correct. I'm not sure if it is worth teaching check-config.py how to ignore this. So I've just accepted the new output.
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 15 Jun 2017 11:10:51 -0700
parents e33c9a47b0db
children 3a64ac39b893
files mercurial/help/config.txt mercurial/profiling.py tests/test-check-config.t
diffstat 3 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/config.txt	Thu Jun 15 11:04:46 2017 -0700
+++ b/mercurial/help/config.txt	Thu Jun 15 11:10:51 2017 -0700
@@ -1580,6 +1580,7 @@
 
     Only used by the ``stat`` profiler.
 
+    For the ``hotpath`` format, default is ``0.05``.
     For the ``chrome`` format, default is ``0.005``.
 
     The option is unused on other formats.
--- a/mercurial/profiling.py	Thu Jun 15 11:04:46 2017 -0700
+++ b/mercurial/profiling.py	Thu Jun 15 11:10:51 2017 -0700
@@ -138,6 +138,9 @@
             showmin = ui.configwith(fraction, 'profiling', 'showmin', 0.005)
             showmax = ui.configwith(fraction, 'profiling', 'showmax', 0.999)
             kwargs.update(minthreshold=showmin, maxthreshold=showmax)
+        elif profformat == 'hotpath':
+            limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
+            kwargs['limit'] = limit
 
         statprof.display(fp, data=data, format=displayformat, **kwargs)
 
--- a/tests/test-check-config.t	Thu Jun 15 11:04:46 2017 -0700
+++ b/tests/test-check-config.t	Thu Jun 15 11:10:51 2017 -0700
@@ -33,3 +33,6 @@
 
   $ hg files "set:(**.py or **.txt) - tests/**" | sed 's|\\|/|g' |
   >   python contrib/check-config.py
+              limit = ui.configwith(fraction, 'profiling', 'showmin', 0.05)
+  
+  conflict on profiling.showmin: ('with', '0.05') != ('with', '0.005')