diff options
| author | Mac Mollison <mollison@cs.unc.edu> | 2010-03-13 16:44:30 -0500 |
|---|---|---|
| committer | Mac Mollison <mollison@cs.unc.edu> | 2010-03-13 16:44:30 -0500 |
| commit | beab41dc5f360324549fd14b3daa8fce613e66ff (patch) | |
| tree | 614660471373e6363e926190d205c4600d7ae4af /scripts/visualize.py | |
| parent | cd82f6c9be132613bfec7eb673923506201e38f6 (diff) | |
Updates included frontend scripts to match doc
Diffstat (limited to 'scripts/visualize.py')
| -rwxr-xr-x | scripts/visualize.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/visualize.py b/scripts/visualize.py new file mode 100755 index 0000000..2b828be --- /dev/null +++ b/scripts/visualize.py | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | #!/usr/bin/python | ||
| 2 | |||
| 3 | ################################################################################ | ||
| 4 | # Description | ||
| 5 | ################################################################################ | ||
| 6 | # This scriipt demonstrates the visualizer submodule. | ||
| 7 | |||
| 8 | # This script should be invoked with the names of the trace files you want to | ||
| 9 | # use. For example, `gedf_test.py ../sample_traces/*.bin`. | ||
| 10 | # You probably want to redirect the (normally lengthy) output to a file! | ||
| 11 | # Otherwise, speed is greatly decreased b/c terminal printing is slow. | ||
| 12 | |||
| 13 | ################################################################################ | ||
| 14 | # Setup | ||
| 15 | ################################################################################ | ||
| 16 | |||
| 17 | # Import the modules we need. You should not need to know about | ||
| 18 | # their internals. | ||
| 19 | import unit_trace | ||
| 20 | from unit_trace import trace_reader | ||
| 21 | from unit_trace import sanitizer | ||
| 22 | from unit_trace import gedf_test | ||
| 23 | from unit_trace import stats | ||
| 24 | from unit_trace import stdout_printer | ||
| 25 | from unit_trace import visualizer | ||
| 26 | |||
| 27 | # Get trace files from command line arguments | ||
| 28 | from optparse import OptionParser | ||
| 29 | parser = OptionParser() | ||
| 30 | (options, traces) = parser.parse_args() | ||
| 31 | traces = list(traces) | ||
| 32 | |||
| 33 | ################################################################################ | ||
| 34 | # Pipeline | ||
| 35 | ################################################################################ | ||
| 36 | |||
| 37 | # Read events from traces | ||
| 38 | stream = trace_reader.trace_reader(traces) | ||
| 39 | |||
| 40 | # Filter out garbage events | ||
| 41 | stream = sanitizer.sanitizer(stream) | ||
| 42 | |||
| 43 | # Produce G-EDF error records | ||
| 44 | stream = gedf_test.gedf_test(stream) | ||
| 45 | |||
| 46 | # Produce a statistics record | ||
| 47 | stream = stats.stats(stream) | ||
| 48 | |||
| 49 | # Filter some records out | ||
| 50 | def my_filter(record): | ||
| 51 | if record.record_type == 'error' and record.type_name == 'inversion_end': | ||
| 52 | if record.job.inversion_end - record.job.inversion_start < 4000000: | ||
| 53 | return False | ||
| 54 | return True | ||
| 55 | #stream = filter(my_filter, stream) | ||
| 56 | |||
| 57 | # It is possible to split the stream in two, | ||
| 58 | # so we can use more than one output mechanism (for example) | ||
| 59 | # without re-doing earlier work. | ||
| 60 | # import itertools | ||
| 61 | # stream1, stream2 = itertools.tee(stream,2) | ||
| 62 | |||
| 63 | # Print the records to stdout | ||
| 64 | visualizer.visualizer(stream) | ||
