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

Gary E. Miller gitlab at mg.gitlab.com
Thu Sep 29 22:32:43 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
e8bcc2a5 by Gary E. Miller at 2016-09-29T15:30:59-07: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.

- - - - -


1 changed file:

- ntpstats/ntpviz


Changes:

=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -22,9 +22,16 @@ 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
+    # finish the profile
+    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 +739,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 +1158,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/commit/e8bcc2a524389b87ada3f4cc9e0de2d5c28c2c54
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160929/bb65674c/attachment.html>


More information about the vc mailing list