Commit e8bcc2a5 authored by Gary E. Miller's avatar Gary E. Miller 💬
Browse files

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.
parent 1f41e1b4
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment