diff options
author | Gary Bressler <garybressler@nc.rr.com> | 2010-04-30 14:51:19 -0400 |
---|---|---|
committer | Gary Bressler <garybressler@nc.rr.com> | 2010-04-30 14:51:19 -0400 |
commit | 9f9bb86ed919bcb6be32b6818ca232f071fe90f3 (patch) | |
tree | 05d97562eb53b7958d022eda02d3f6134850e0d9 | |
parent | c21dea9f97dd31ad8a915469edc01f44345a469e (diff) |
Added ability to specify units along with -t command-line option
-rw-r--r-- | doc/index.txt | 13 | ||||
-rwxr-xr-x | unit-trace | 10 | ||||
-rw-r--r-- | unit_trace/viz/__init__.py | 4 | ||||
-rw-r--r-- | unit_trace/viz/util.py | 23 | ||||
-rw-r--r-- | unit_trace/viz/viewer.py | 8 |
5 files changed, 46 insertions, 12 deletions
diff --git a/doc/index.txt b/doc/index.txt index e24eb2a..2e80281 100644 --- a/doc/index.txt +++ b/doc/index.txt | |||
@@ -107,6 +107,14 @@ Some submodules have further documentation, appearing later in this document. | |||
107 | <tr><td>visualizer</td><td>-v</td><td>(None)</td><td>Visualizes records. You should probably use filters in conjunction with this submodule. Otherwise, it'll take forever to render, and do you <i>really</i> want to visualize the <i>entire</i> trace, anyway?</td></tr> | 107 | <tr><td>visualizer</td><td>-v</td><td>(None)</td><td>Visualizes records. You should probably use filters in conjunction with this submodule. Otherwise, it'll take forever to render, and do you <i>really</i> want to visualize the <i>entire</i> trace, anyway?</td></tr> |
108 | <tr><td>gedf_inversion_stat_printer</td><td>-i</td><td>number n</td><td>Outputs statistics about G-EDF inversions, and the n longest inversions. (You can specify n as 0 if you want.)</td></tr> | 108 | <tr><td>gedf_inversion_stat_printer</td><td>-i</td><td>number n</td><td>Outputs statistics about G-EDF inversions, and the n longest inversions. (You can specify n as 0 if you want.)</td></tr> |
109 | </table> | 109 | </table> |
110 | ### Submodule Options ### | ||
111 | <table border=1> | ||
112 | <tr><th>Name</th><th>Flag</th><th>Options</th><th>Description</th></tr> | ||
113 | <tr><td>time_per_maj</td><td>-t</td><td>Time per major tick [Optional unit]</td><td> | ||
114 | This option controls how much time is between each major tick in the visualizer. It should take the form of a number | ||
115 | with, optionally, an SI unit appended (`ns`, `us`, `ms`, `s` are supported). If you don't specify a unit, unit-trace assumes | ||
116 | the time to be in milliseconds. </td> | ||
117 | </table> | ||
110 | ### Miscellaneous Submodules ### | 118 | ### Miscellaneous Submodules ### |
111 | <table border=1> | 119 | <table border=1> |
112 | <tr><th>Name</th><th>Flag</th><th>Options</th><th>Description</th></tr> | 120 | <tr><th>Name</th><th>Flag</th><th>Options</th><th>Description</th></tr> |
@@ -233,9 +241,12 @@ Here, documentation is provided for potentially confusing topics that are not do | |||
233 | In general, Unit-Trace is agnostic about the units of time used in the trace files. | 241 | In general, Unit-Trace is agnostic about the units of time used in the trace files. |
234 | This is not expected to change in the future. | 242 | This is not expected to change in the future. |
235 | The exception is output modules. | 243 | The exception is output modules. |
236 | Currently, some output modules assume time is in nanoseconds; they convert it into milliseconds and print the 'ms' unit indicator, where convenient. | 244 | Currently, some output modules assume time is in nanoseconds; they convert it into milliseconds. |
237 | This behavior may have to be modified in the future if non-nanosecond trace files are used. | 245 | This behavior may have to be modified in the future if non-nanosecond trace files are used. |
238 | 246 | ||
247 | However, when specifying time intervals in certain situations for output modules, | ||
248 | you can specify the units, the default being milliseconds (see the information for the `-v` option). | ||
249 | |||
239 | ## Known Bugs ## | 250 | ## Known Bugs ## |
240 | 251 | ||
241 | Here, documentation of known bugs is provided. | 252 | Here, documentation of known bugs is provided. |
@@ -27,7 +27,7 @@ parser.add_option("-o", "--stdout", action="store_true", dest="stdout", | |||
27 | default=False, help="Use stdout_printer") | 27 | default=False, help="Use stdout_printer") |
28 | parser.add_option("-v", "--visual", action="store_true", dest="visualize", | 28 | parser.add_option("-v", "--visual", action="store_true", dest="visualize", |
29 | default=False, help="Use visualizer") | 29 | default=False, help="Use visualizer") |
30 | parser.add_option("-t", "--time-per-maj", default=10000000.0, type=float, | 30 | parser.add_option("-t", "--time-per-maj", default='10ms', type=str, |
31 | dest="time_per_maj", help="Time interval between major ticks, in the visualizer") | 31 | dest="time_per_maj", help="Time interval between major ticks, in the visualizer") |
32 | parser.add_option("-c", "--clean", action="store_true", dest="clean", | 32 | parser.add_option("-c", "--clean", action="store_true", dest="clean", |
33 | default=False, help="Use sanitizer to clean garbage records") | 33 | default=False, help="Use sanitizer to clean garbage records") |
@@ -120,4 +120,10 @@ if options.num_inversions > -1: | |||
120 | # Call visualizer | 120 | # Call visualizer |
121 | if options.visualize is True: | 121 | if options.visualize is True: |
122 | from unit_trace import viz | 122 | from unit_trace import viz |
123 | viz.visualizer.visualizer(stream3, options.time_per_maj) | 123 | try: |
124 | nsec_time_per_maj = viz.util.parse_time(options.time_per_maj) | ||
125 | viz.visualizer.visualizer(stream3, nsec_time_per_maj) | ||
126 | except ValueError: | ||
127 | import sys | ||
128 | sys.stderr.write("Time expression should be of the form [TIME] [UNIT]") | ||
129 | |||
diff --git a/unit_trace/viz/__init__.py b/unit_trace/viz/__init__.py index 91093c1..118a026 100644 --- a/unit_trace/viz/__init__.py +++ b/unit_trace/viz/__init__.py | |||
@@ -11,8 +11,8 @@ try: | |||
11 | except ImportError: | 11 | except ImportError: |
12 | import sys | 12 | import sys |
13 | 13 | ||
14 | print 'Unit-Trace could not find pycairo and/or pygtk installed on your system. Please\n' \ | 14 | sys.stderr.write('Unit-Trace could not find pycairo and/or pygtk installed on your system. Please\n' \ |
15 | + 'make sure these libraries are installed before attempting to use the visualizer.' | 15 | + 'make sure these libraries are installed before attempting to use the visualizer.') |
16 | sys.exit(1) | 16 | sys.exit(1) |
17 | 17 | ||
18 | gobject.signal_new('set-scroll-adjustments', viewer.GraphArea, gobject.SIGNAL_RUN_FIRST, | 18 | gobject.signal_new('set-scroll-adjustments', viewer.GraphArea, gobject.SIGNAL_RUN_FIRST, |
diff --git a/unit_trace/viz/util.py b/unit_trace/viz/util.py index 430063b..12d65f4 100644 --- a/unit_trace/viz/util.py +++ b/unit_trace/viz/util.py | |||
@@ -63,6 +63,29 @@ class Sec(TimeUnit): | |||
63 | if time is None: return time | 63 | if time is None: return time |
64 | return time * 1000000000.0 | 64 | return time * 1000000000.0 |
65 | 65 | ||
66 | def parse_time(text): | ||
67 | # perhaps the user didn't put a space between the number and | ||
68 | # the time unit | ||
69 | for i, char in enumerate(text): | ||
70 | if char == ' ': | ||
71 | break | ||
72 | elif char.isalpha(): | ||
73 | text = text[0:i] + ' ' + text[i:] | ||
74 | break | ||
75 | |||
76 | tokens = text.split() | ||
77 | |||
78 | if len(tokens) > 2 or len(tokens) == 0: | ||
79 | raise ValueError | ||
80 | |||
81 | unit = None | ||
82 | if len(tokens) == 2: | ||
83 | unit = parse_unit(tokens[1]) | ||
84 | else: | ||
85 | unit = MilliSec() | ||
86 | |||
87 | return unit.native_to_nsec(float(tokens[0])) | ||
88 | |||
66 | def parse_unit(expr): | 89 | def parse_unit(expr): |
67 | expr = expr.strip().lower() | 90 | expr = expr.strip().lower() |
68 | 91 | ||
diff --git a/unit_trace/viz/viewer.py b/unit_trace/viz/viewer.py index bb1385c..4613c47 100644 --- a/unit_trace/viz/viewer.py +++ b/unit_trace/viz/viewer.py | |||
@@ -856,14 +856,8 @@ class MainWindow(gtk.Window): | |||
856 | if ret == gtk.RESPONSE_ACCEPT: | 856 | if ret == gtk.RESPONSE_ACCEPT: |
857 | err, time = None, None | 857 | err, time = None, None |
858 | try: | 858 | try: |
859 | input_tokens = self.text_input_dialog.get_input().split() | 859 | time = util.parse_time(self.text_input_dialog.get_input()) |
860 | if len(input_tokens) > 2: | ||
861 | raise ValueError | ||
862 | 860 | ||
863 | if len(input_tokens) > 1: | ||
864 | unit = util.parse_unit(input_tokens[1]) | ||
865 | |||
866 | time = unit.native_to_nsec(float(input_tokens[0])) | ||
867 | start, end = self.notebook.get_nth_page(self.notebook.last_page).get_graph_area() \ | 861 | start, end = self.notebook.get_nth_page(self.notebook.last_page).get_graph_area() \ |
868 | .get_schedule().get_time_bounds() | 862 | .get_schedule().get_time_bounds() |
869 | if time < start or time > end: | 863 | if time < start or time > end: |