diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-09-24 11:57:39 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-09-24 11:57:39 -0400 |
commit | 6a3ab18e25b426ebc0bf46daee9c097f2a3904b3 (patch) | |
tree | b6f9ac36711172b4562a48571591d5eb7dbf43e6 | |
parent | 19be03197eb34f31b36e1b6cdef4ab8f29de1e0b (diff) | |
download | gpsd-6a3ab18e25b426ebc0bf46daee9c097f2a3904b3.tar.gz |
Change the semantics of gpsprof -d so we can both dump and plot in one run.
-rwxr-xr-x | gpsprof | 32 | ||||
-rw-r--r-- | gpsprof.xml | 6 |
2 files changed, 21 insertions, 17 deletions
@@ -219,7 +219,7 @@ class spaceplot(plotter): class uninstrumented(plotter): "Total times without instrumentation." name = "uninstrumented" - requires_time = True + requires_time = False def __init__(self): plotter.__init__(self) def sample(self): @@ -246,7 +246,7 @@ plot "-" using 0:1 title "Total time" with impulses return fmt + self.header() + self.data() class instrumented(plotter): - "All measurement, no deductions." + "Latency as analyzed by instrumentation." name = "instrumented" requires_time = True def __init__(self): @@ -292,7 +292,7 @@ formatters = (spaceplot, uninstrumented, instrumented) if __name__ == '__main__': try: - (options, arguments) = getopt.getopt(sys.argv[1:], "df:hm:n:s:t:T:D:") + (options, arguments) = getopt.getopt(sys.argv[1:], "d:f:hm:n:s:t:T:D:") plotmode = "space" raw = False @@ -301,7 +301,7 @@ if __name__ == '__main__': await = 100 verbose = 0 terminal = None - dump = False + dumpfile = None for (switch, val) in options: if (switch == '-f'): plotmode = val @@ -314,7 +314,7 @@ if __name__ == '__main__': elif (switch == '-T'): terminal = val elif (switch == '-d'): - dump = True + dumpfile = val elif (switch == '-D'): verbose = int(val) elif (switch == '-h'): @@ -322,6 +322,7 @@ if __name__ == '__main__': "usage: gpsprof [-h] [-D debuglevel] [-m threshold] [-n samplecount] [-d]\n" + "\t[-f {" + "|".join(map(lambda x: x.name, formatters)) + "}] [-s speed] [-t title] [-T terminal]\n") sys.exit(0) + # Select the plotting mode if plotmode: for formatter in formatters: if formatter.name == plotmode: @@ -330,16 +331,19 @@ if __name__ == '__main__': else: sys.stderr.write("gpsprof: no such formatter.\n") sys.exit(1) + # Get fix data from the GPS plotter.collect(verbose) - if dump: - sys.stdout.write(plotter.dump()) - else: - if terminal: - sys.stdout.write("set terminal %s\n" % terminal) - sys.stdout.write(plotter.plot()) - if not title: - title = plotter.whatami() - sys.stdout.write("set title %s\n" % title) + # Save the raw data for post-analysis if required. + if dumpfile: + with open(dumpfile) as fp: + fp.write(plotter.dump()) + # Ship the plot to standard output + if terminal: + sys.stdout.write("set terminal %s\n" % terminal) + sys.stdout.write(plotter.plot()) + if not title: + title = plotter.whatami() + sys.stdout.write("set title %s\n" % title) except KeyboardInterrupt: pass diff --git a/gpsprof.xml b/gpsprof.xml index c68b5d78..dfa957d2 100644 --- a/gpsprof.xml +++ b/gpsprof.xml @@ -27,7 +27,7 @@ BSD terms apply: see the file COPYING in the distribution root for details. <arg choice='opt'>-n <replaceable>packetcount</replaceable></arg> <arg choice='opt'>-t <replaceable>title</replaceable></arg> <arg choice='opt'>-T <replaceable>terminal</replaceable></arg> - <arg choice='opt'>-d</arg> + <arg choice='opt'>-d <replaceable>dumpfile</replaceable></arg> <arg choice='opt'>-D <replaceable>debuglevel</replaceable></arg> <arg choice='opt'>-h</arg> </cmdsynopsis> @@ -158,8 +158,8 @@ title.</para> Typical usage is "-T png" telling gnuplot to write a PNG file. Without this option gnuplot will call its X11 display code.</para> -<para>The -d option suppresses plot generation, dumping the plot data instead. -This option is a no-op with the space plot.</para> +<para>The -d option dumps the raw plot data to a specified file for +pos-analysis.</para> <para>The -h option makes <application>gpsprof</application> print a usage message and exit.</para> |