[Git][NTPsec/ntpsec][master] 6 commits: ntpviz: comment tweaking

Gary E. Miller gitlab at mg.gitlab.com
Wed Oct 26 02:35:05 UTC 2016


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


Commits:
84af1347 by Gary E. Miller at 2016-10-25T13:25:37-07:00
ntpviz: comment tweaking

document some commonly held urban legends on how to speed up
Python as being demonstrated false.

- - - - -
e4d55a31 by Gary E. Miller at 2016-10-25T18:08:43-07:00
ntpviz: minor cleanup in plot_histogram()

- - - - -
0c3f17d3 by Gary E. Miller at 2016-10-25T18:23:15-07:00
ntpviz: remove unused, broken, NTPStats.dump()

- - - - -
bc06163b by Gary E. Miller at 2016-10-25T18:33:14-07:00
ntpviz: remove an unneeded 'if'

- - - - -
49e2d2ba by Gary E. Miller at 2016-10-25T18:42:56-07:00
ntpviz: remove pointless cast of lists to lists.

- - - - -
5ec18f6d by Gary E. Miller at 2016-10-25T18:59:51-07:00
ntpviz: reshape the png's a bit.

in 2016, 25% of screens are 1024x768, 42% are 1388x768.  So use
that space, but leave some room for the browser frame.

- - - - -


2 changed files:

- ntpstats/ntpviz
- pylib/statfiles.py


Changes:

=====================================
ntpstats/ntpviz
=====================================
--- a/ntpstats/ntpviz
+++ b/ntpstats/ntpviz
@@ -292,19 +292,22 @@ def gnuplot(template, outfile=None):
 
 class NTPViz(NTPStats):
     "Class for visualizing statistics from a single server."
+
+    # in 2016, 25% of screens are 1024x768, 42% are 1388x768
+    # but leave some room for the browser frame
     # Python takes single quotes here. Since no % substitution
     Common = """\
-set terminal png size 900,650
+set terminal png size 1000,650
 set grid
 set autoscale xfixmin
 set autoscale xfixmax
 set xdata time
-set xtic rotate by -45 scale 0
+set xtic rotate by -35 scale 0
 set xlabel "Time (DDMM hh:mm UTC)"
 set format x "%d%b %H:%M"
 set timefmt "%s"
-set lmargin 12
-set rmargin 12
+set lmargin 10
+set rmargin 10
 """
 
     def __init__(self, statsdir,
@@ -336,6 +339,7 @@ set rmargin 12
                 plot_data += row[1] + ' ' + row[item1] + '\n'
         # I know you want to replace the plot_data string concat with
         # or more join()s, do not do it, it is slower
+        # next you'll want to try %-subsitution.  it too is slower
         plot_data += "e\n"
         return plot_data
 
@@ -401,7 +405,7 @@ file.</p>
         "Generate GNUPLOT code graphing local temperature statistics"
         sitename = self.sitename
         tempsmap = self.tempssplit()
-        tempslist = list(tempsmap.keys())
+        tempslist = tempsmap.keys()
         tempslist.sort()
 
         if not len( tempsmap) or not len( tempslist):
@@ -446,7 +450,7 @@ component of frequency drift.</p>
         "Generate GNUPLOT code graphing local gps statistics"
         sitename = self.sitename
         gpsmap = self.gpssplit()
-        gpslist = list(gpsmap.keys())
+        gpslist = gpsmap.keys()
         gpslist.sort()
 
         if not len( gpsmap) or not len( gpslist):
@@ -620,7 +624,7 @@ plot \
 
         peerdict = self.peersplit()
         if not peerlist:
-            peerlist = list(peerdict.keys())
+            peerlist = peerdict.keys()
         if not len( peerlist):
             sys.stderr.write("ntpviz: WARNING: no peer data to graph\n")
             return ''
@@ -839,7 +843,6 @@ plot \
         out['min_x']    = out['min_y']
         out['max_x']    = out['max_y']
 
-        # fixme, should piggy back on unit
         rnd1 = 7        # round to 100 ns boxes
         out['boxwidth'] = 1e-7
 
@@ -852,7 +855,7 @@ plot \
         for value in values:
             # put into buckets
             # for a +/- 50 microSec range that is 1,000 buckets to plot
-            cnt[ round( float(value), rnd1)] += 1
+            cnt[ round( value, rnd1)] += 1
 
         sigma = True
         if args.clip:
@@ -874,11 +877,13 @@ set label 2 "+1σ" at %(p1sigma)s, graph 0.96  left front offset -1,-1
 """ % out
 
 
+        # in 2016, 25% of screens are 1024x768, 42% are 1388x768
+        # but leave some room for the browser frame
         plot_template = '''\
-set terminal png size 900,600
+set terminal png size 1000,650
 set grid
 set boxwidth %(boxwidth)s
-set xtic rotate by -45 scale 0
+set xtic rotate by -35 scale 0
 set title "%(sitename)s: Local Clock Time Offset Histogram%(clipped)s"
 set xtics format "%%1.1f %(unit)s" nomirror
 set xrange [%(min_x)s:%(max_x)s]
@@ -891,8 +896,8 @@ set arrow from %(p5)s,graph 0 to %(p5)s,graph 0.45 as 5
 set style arrow 6 nohead
 set arrow from %(p1)s,graph 0 to %(p1)s,graph 0.30 as 6
 set key off
-set lmargin 12
-set rmargin 12
+set lmargin 10
+set rmargin 10
 set style fill solid 0.5
 set label 3 "99%%" at %(p99)s, graph 0.35  left front offset -1,-1
 set label 4 "95%%" at %(p95)s, graph 0.50  left front offset -1,-1
@@ -903,9 +908,7 @@ plot \
  "-" using ($1 * %(multiplier)s):2 title "histogram" with boxes
 ''' % out
 
-        vals = list(cnt.keys())
-        vals.sort()
-        histogram_data = ["%s %s\n" % (val, cnt[val]) for val in vals]
+        histogram_data = ["%s %s\n" % (k, v) for k,v in cnt.items() ]
 
         exp = """\
 <p>This shows the clock offsets of the local clock as a histogram.</p>
@@ -1458,7 +1461,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
             ("peer-offsets", stats.peer_offsets_gnuplot()),
         ]
 
-        peerlist = list(stats.peersplit().keys())
+        peerlist = stats.peersplit().keys()
         # sort for output order stability
         peerlist.sort()
         for key in peerlist:


=====================================
pylib/statfiles.py
=====================================
--- a/pylib/statfiles.py
+++ b/pylib/statfiles.py
@@ -99,18 +99,17 @@ class NTPStats:
             if stem == "temps" or stem == "gpsd":
                 # temps and gpsd are already in UNIX time
                 for line in lines:
-                    if line is not None:
-                        try:
-                            split = line.split()
-                            t = float(split[0])
-                        except:
-                            # ignore comment lines, lines with no time
-                            continue
-
-                        if starttime <= t <= endtime:
-                            # prefix with int milli sec.
-                            split.insert(0, int(t * 1000))
-                            lines1.append( split)
+                    split = line.split()
+                    try:
+                        t = float(split[0])
+                    except:
+                        # ignore comment lines, lines with no time
+                        continue
+
+                    if starttime <= t <= endtime:
+                        # prefix with int milli sec.
+                        split.insert(0, int(t * 1000))
+                        lines1.append( split)
             else:
                 # Morph first fields into Unix time with fractional seconds
                 # ut into nice dictionary of dictionary rows
@@ -168,10 +167,6 @@ class NTPStats:
             tempsmap[source].append(row)
         return tempsmap
 
-    def dump(self, row):
-        "dump a stored list of logfile entries"
-        return "\n".join(getattr(self, row)) + "\n"
-
     def ip_label(self, key):
         "Produce appropriate label for an IP address."
         # If it's a new-style NTPsep clock label, pass it through,



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/8b936c0c5e9b4dc91cb55c2b7e5b51cafae9f50e...5ec18f6d5e1fcf3e35262dbbb61a2f27c145687f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161026/2345cb1d/attachment.html>


More information about the vc mailing list