summaryrefslogtreecommitdiff
path: root/gpsprof
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-09-20 22:52:57 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-09-20 22:52:57 -0400
commita6f1d32121b7ce8b4cb9485f238eb62f23b75c7e (patch)
tree5fba20ea0ee790ac3b9373a237856c89bf4f9152 /gpsprof
parente9034a445991b1fdceb6d536f5415b320c049e6a (diff)
downloadgpsd-a6f1d32121b7ce8b4cb9485f238eb62f23b75c7e.tar.gz
Remove the old latency-profiling machinery.
It hasn't actually worked since we switched protocols to JSON. This diff puts the framework in place for new machinery using timing attributes in the TPV sentence.
Diffstat (limited to 'gpsprof')
-rwxr-xr-xgpsprof202
1 files changed, 2 insertions, 200 deletions
diff --git a/gpsprof b/gpsprof
index 099d7f03..e688cac1 100755
--- a/gpsprof
+++ b/gpsprof
@@ -42,7 +42,7 @@ class Baton:
return
class spaceplot:
- "Total times without instrumentation."
+ "Spatial scattergram of fixes."
name = "space"
def __init__(self):
self.fixes = []
@@ -184,205 +184,7 @@ plot "-" using 0:1 title "Total time" with impulses
res += self.header(session)
return res + self.data(session)
-class rawplot:
- "All measurement, no deductions."
- name = "raw"
- def __init__(self):
- self.stats = []
- def gather(self, session):
- self.stats.append(copy.copy(session.timings))
- return True
- def header(self, session):
- res = "# Raw latency data, %s, %s, %dN%d, cycle %ds\n" % \
- (title,
- session.gps_id, session.baudrate,
- session.stopbits, session.cycle)
- res += "# tag len xmit "
- for hn in ("T1", "D1", "E2", "T2", "D2"):
- res += "%-13s" % hn
- res += "\n#------- ----- --------------------"
- res += (" " + ("-" * 11)) * 5
- return res + "\n"
- def data(self, unused):
- res = ""
- for timings in self.stats:
- res += "% 8s %4d %2.9f %2.9f %2.9f %2.9f %2.9f %2.9f\n" \
- % (timings.tag,
- timings.len,
- timings.xmit,
- timings.recv - timings.xmit,
- timings.decode - timings.recv,
- timings.emit - timings.decode,
- timings.c_recv - timings.emit,
- timings.c_decode - timings.c_recv)
- return res
- def plot(self, unused, session):
- fmt = '''
-set autoscale
-set key below
-set key title "Raw latency data, %s, %s, %dN%d, cycle %ds"
-plot \
- "-" using 0:8 title "D2 = Client decode time" with impulses, \
- "-" using 0:7 title "T2 = TCP/IP latency" with impulses, \
- "-" using 0:6 title "E2 = Daemon encode time" with impulses, \
- "-" using 0:5 title "D1 = Daemon decode time" with impulses, \
- "-" using 0:4 title "T1 = RS232 time" with impulses
-'''
- res = fmt % (title,
- session.gps_id, session.baudrate,
- session.stopbits, session.cycle)
- res += self.header(session)
- res += (self.data(session) + "e\n") * 5
- return res
-
-class splitplot:
- "Discard base time, use color to indicate different tags."
- name = "split"
- sentences = []
- def __init__(self):
- self.stats = []
- def gather(self, session):
- self.stats.append(copy.copy(session.timings))
- if session.timings.tag not in self.sentences:
- self.sentences.append(session.timings.tag)
- return True
- def header(self, session):
- res = "# Split latency data, %s, %s, %dN%d, cycle %ds\n#" % \
- (title,
- session.gps_id, session.baudrate,
- session.stopbits, session.cycle)
- for s in splitplot.sentences:
- res += "%8s\t" % s
- for hn in ("T1", "D1", "E2", "T2", "D2", "length"):
- res += "%8s\t" % hn
- res += "tag\n# "
- for s in tuple(splitplot.sentences) + ("T1", "D1", "E2", "T2", "D2", "length"):
- res += "---------\t"
- return res + "--------\n"
- def data(self, unused):
- res = ""
- for timings in self.stats:
- for s in splitplot.sentences:
- if s == timings.tag:
- res += "%2.6f\t" % timings.xmit
- else:
- res += "- \t"
- res += "%2.6f\t%2.6f\t%2.6f\t%2.6f\t%2.6f\t%8d\t# %s\n" \
- % (timings.recv - timings.xmit,
- timings.decode - timings.recv,
- timings.emit - timings.decode,
- timings.c_recv - timings.emit,
- timings.c_decode - timings.c_recv,
- timings.len,
- timings.tag)
- return res
- def plot(self, title, session):
- fixed = '''
-set autoscale
-set key below
-set key title "Filtered latency data, %s, %s, %dN%d, cycle %ds"
-plot \
- "-" using 0:%d title "D2 = Client decode time" with impulses, \
- "-" using 0:%d title "T2 = TCP/IP latency" with impulses, \
- "-" using 0:%d title "E2 = Daemon encode time" with impulses, \
- "-" using 0:%d title "D1 = Daemon decode time" with impulses, \
- "-" using 0:%d title "T1 = RS232 time" with impulses, \
-'''
- sc = len(splitplot.sentences)
- fmt = fixed % (title,
- session.gps_id, session.baudrate,
- session.stopbits, session.cycle,
- sc+5,
- sc+4,
- sc+3,
- sc+2,
- sc+1)
- for i in range(sc):
- fmt += ' "-" using 0:%d title "%s" with impulses,' % \
- (i+1, self.sentences[i])
- res = fmt[:-1] + "\n"
- res += self.header(session)
- res += (self.data(session) + "e\n") * (sc + 5)
- return res
-
-class cycle:
- "Send-cycle analysis."
- name = "cycle"
- def __init__(self):
- self.stats = []
- def gather(self, session):
- self.stats.append(copy.copy(session.timings))
- return True
- def plot(self, title, session):
- msg = ""
- def roundoff(n):
- # Round a time to hundredths of a second
- return round(n*100) / 100.0
- intervals = {}
- last_seen = {}
- last_command = ""
- for timing in self.stats:
- # Throw out everything but the leader in each GSV group
- if timing.tag[-3:] == "GSV" and last_command[-3:] == "GSV":
- continue
- last_command = timing.tag
- # Record timings
- received = timing.d_received()
- if not timing.tag in intervals:
- intervals[timing.tag] = []
- if timing.tag in last_seen:
- intervals[timing.tag].append(roundoff(received - last_seen[timing.tag]))
- last_seen[timing.tag] = received
-
- # Step three: get command frequencies and the basic send cycle time
- frequencies = {}
- for (key, interval_list) in intervals.items():
- frequencies[key] = {}
- for interval in interval_list:
- frequencies[key][interval] = frequencies[key].get(interval, 0) + 1
- # filter out noise
- for key in frequencies:
- distribution = frequencies[key]
- for interval in distribution.keys():
- if distribution[interval] < 2:
- del distribution[interval]
- cycles = {}
- for key in frequencies:
- distribution = frequencies[key]
- if len(frequencies[key].values()) == 1:
- # The value is uniqe after filtering
- cycles[key] = distribution.keys()[0]
- else:
- # Compute the mode
- maxfreq = 0
- for (interval, frequency) in distribution.items():
- if distribution[interval] > maxfreq:
- cycles[key] = interval
- maxfreq = distribution[interval]
- msg += "Cycle report %s, %s, %dN%d, cycle %ds" % \
- (title,
- session.gps_id, session.baudrate,
- session.stopbits, session.cycle)
- msg += "The sentence set emitted by this GPS is: %s\n" % " ".join(intervals.keys())
- for key in cycles:
- if len(frequencies[key].values()) == 1:
- if cycles[key] == 1:
- msg += "%s: is emitted once a second.\n" % key
- else:
- msg += "%s: is emitted once every %d seconds.\n" % (key, cycles[key])
- else:
- if cycles[key] == 1:
- msg += "%s: is probably emitted once a second.\n" % key
- else:
- msg += "%s: is probably emitted once every %d seconds.\n" % (key, cycles[key])
- sendcycle = min(*cycles.values())
- if sendcycle == 1:
- msg += "Send cycle is once per second.\n"
- else:
- msg += "Send cycle is once per %d seconds.\n" % sendcycle
- return msg
-
-formatters = (spaceplot, uninstrumented, rawplot, splitplot, cycle)
+formatters = (spaceplot, uninstrumented)
def plotframe(await, fname, speed, threshold, title):
"Return a string containing a GNUplot script "