summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-03-13 16:44:30 -0500
committerMac Mollison <mollison@cs.unc.edu>2010-03-13 16:44:30 -0500
commitbeab41dc5f360324549fd14b3daa8fce613e66ff (patch)
tree614660471373e6363e926190d205c4600d7ae4af
parentcd82f6c9be132613bfec7eb673923506201e38f6 (diff)
Updates included frontend scripts to match doc
-rwxr-xr-xscripts/gedf_test.py64
-rwxr-xr-xscripts/visualize.py (renamed from sample_script.py)37
2 files changed, 82 insertions, 19 deletions
diff --git a/scripts/gedf_test.py b/scripts/gedf_test.py
new file mode 100755
index 0000000..385f424
--- /dev/null
+++ b/scripts/gedf_test.py
@@ -0,0 +1,64 @@
1#!/usr/bin/python
2
3################################################################################
4# Description
5################################################################################
6# This script performs a G-EDF test and outputs the results to std out.
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.
19import unit_trace
20from unit_trace import trace_reader
21from unit_trace import sanitizer
22from unit_trace import gedf_test
23from unit_trace import stats
24from unit_trace import stdout_printer
25from unit_trace import visualizer
26
27# Get trace files from command line arguments
28from optparse import OptionParser
29parser = OptionParser()
30(options, traces) = parser.parse_args()
31traces = list(traces)
32
33################################################################################
34# Pipeline
35################################################################################
36
37# Read events from traces
38stream = trace_reader.trace_reader(traces)
39
40# Filter out garbage events
41stream = sanitizer.sanitizer(stream)
42
43# Produce G-EDF error records
44stream = gedf_test.gedf_test(stream)
45
46# Produce a statistics record
47stream = stats.stats(stream)
48
49# Filter some records out
50def 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
64stdout_printer.stdout_printer(stream)
diff --git a/sample_script.py b/scripts/visualize.py
index a5fed86..2b828be 100755
--- a/sample_script.py
+++ b/scripts/visualize.py
@@ -3,9 +3,12 @@
3################################################################################ 3################################################################################
4# Description 4# Description
5################################################################################ 5################################################################################
6# This is a sample script for using the tool. I would recommend copying 6# This scriipt demonstrates the visualizer submodule.
7# this and modifying it to suit your needs for a particular test. Make 7
8# sure you redirect the output to a file (e.g. ./sample_script.py > output). 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.
9 12
10################################################################################ 13################################################################################
11# Setup 14# Setup
@@ -21,20 +24,18 @@ from unit_trace import stats
21from unit_trace import stdout_printer 24from unit_trace import stdout_printer
22from unit_trace import visualizer 25from unit_trace import visualizer
23 26
24# Specify your trace files 27# Get trace files from command line arguments
25g6 = [ 28from optparse import OptionParser
26'./sample_traces/st-g6-0.bin', 29parser = OptionParser()
27'./sample_traces/st-g6-1.bin', 30(options, traces) = parser.parse_args()
28'./sample_traces/st-g6-2.bin', 31traces = list(traces)
29'./sample_traces/st-g6-3.bin',
30]
31 32
32################################################################################ 33################################################################################
33# Pipeline 34# Pipeline
34################################################################################ 35################################################################################
35 36
36# Read events from traces 37# Read events from traces
37stream = trace_reader.trace_reader(g6) 38stream = trace_reader.trace_reader(traces)
38 39
39# Filter out garbage events 40# Filter out garbage events
40stream = sanitizer.sanitizer(stream) 41stream = sanitizer.sanitizer(stream)
@@ -46,7 +47,6 @@ stream = gedf_test.gedf_test(stream)
46stream = stats.stats(stream) 47stream = stats.stats(stream)
47 48
48# Filter some records out 49# Filter some records out
49# NOTE: Currently, this will break the Visualizer if enabled
50def my_filter(record): 50def my_filter(record):
51 if record.record_type == 'error' and record.type_name == 'inversion_end': 51 if record.record_type == 'error' and record.type_name == 'inversion_end':
52 if record.job.inversion_end - record.job.inversion_start < 4000000: 52 if record.job.inversion_end - record.job.inversion_start < 4000000:
@@ -54,12 +54,11 @@ def my_filter(record):
54 return True 54 return True
55#stream = filter(my_filter, stream) 55#stream = filter(my_filter, stream)
56 56
57# Split the stream in two, so we can use both output mechanisms 57# It is possible to split the stream in two,
58import itertools 58# so we can use more than one output mechanism (for example)
59stream1, stream2 = itertools.tee(stream,2) 59# without re-doing earlier work.
60# import itertools
61# stream1, stream2 = itertools.tee(stream,2)
60 62
61# Print the records to stdout 63# Print the records to stdout
62stdout_printer.stdout_printer(stream1) 64visualizer.visualizer(stream)
63
64# Visualize the records
65visualizer.visualizer(stream2)