[Git][NTPsec/ntpsec][master] 2 commits: Enable profiling of more options.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Oct 2 13:51:24 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
0008ac2c by Gary E. Miller at 2016-10-02T09:49:01-04:00
Enable profiling of more options.

Profiling is enabled by -D9.  It only worked when all the graphs, and
html were generated.  By making the profile dump an atexit() the
prilfe now works on all ways you can run ntpviz.

- - - - -
a5814c31 by Gary E. Miller at 2016-10-02T09:49:42-04:00
More standard def format for print_profile().

- - - - -


1 changed file:

- ntpstats/ntpviz


Changes:

=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -22,9 +22,15 @@ Python by ESR, concept and GNUPLOT code by Dan Drown.
 #SPDX-License-Identifier: BSD-2-Clause
 from __future__ import print_function, division
 
-import binascii, collections, getopt, os, socket, sys, time
+import atexit, binascii, collections, getopt, os, socket, sys, time
 from ntp.statfiles import *
 
+def print_profile():
+    """called by atexit() on normal exit to print profile data"""
+    pr.disable()
+    pr.print_stats('tottime')
+    pr.print_stats('cumtime')
+
 # standard deviation functions
 # use this until we can guarantee Python 3.4 and the statistics module
 # http://stackoverflow.com/questions/15389768/standard-deviation-of-a-list#21505523
@@ -732,6 +738,10 @@ if __name__ == '__main__':
             pr = cProfile.Profile()
             pr.enable()
 
+            # register to dump debug on all normal exits
+            atexit.register( print_profile )
+
+
     nice = 19       # always run nicely
     if 0 != nice:
         try:
@@ -1147,11 +1157,4 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
         ifile.write(index_buffer)
         ifile.close()
 
-
-if 9 == debug_level:
-    # finish the profile
-    pr.disable()
-    pr.print_stats('tottime')
-    pr.print_stats('cumtime')
-
 # end



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/4379e60ec1c05458198eafdeabae66fca0739348...a5814c31bc01e1f46555c000ee505a5267ac90a8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161002/5eec0d2b/attachment.html>


More information about the vc mailing list