summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2010-03-26 16:34:21 -0400
committerMac Mollison <mollison@cs.unc.edu>2010-03-26 16:34:21 -0400
commited309ed19e2ba5d4172e886b496ca3c40c3d3634 (patch)
treee6aa012f84ca4fb92aa744297b4d9d0aece35a2d
parent13b237b07c09942b6229c23a81f200b2565475ca (diff)
Refactored stats module to be an output module
Previously this was an "intermediate" module. Makes more sense to have it as an output module.
-rwxr-xr-xunit-trace31
-rw-r--r--unit_trace/gedf_inversion_stat_printer.py (renamed from unit_trace/stats.py)44
-rw-r--r--unit_trace/stdout_printer.py10
3 files changed, 45 insertions, 40 deletions
diff --git a/unit-trace b/unit-trace
index d0921d5..81b6c02 100755
--- a/unit-trace
+++ b/unit-trace
@@ -15,7 +15,7 @@ import unit_trace
15from unit_trace import trace_reader 15from unit_trace import trace_reader
16from unit_trace import sanitizer 16from unit_trace import sanitizer
17from unit_trace import gedf_test 17from unit_trace import gedf_test
18from unit_trace import stats 18from unit_trace import gedf_inversion_stat_printer
19from unit_trace import stdout_printer 19from unit_trace import stdout_printer
20from unit_trace import viz 20from unit_trace import viz
21from unit_trace import progress 21from unit_trace import progress
@@ -90,10 +90,6 @@ if options.progress is True:
90if options.gedf is True: 90if options.gedf is True:
91 stream = gedf_test.gedf_test(stream) 91 stream = gedf_test.gedf_test(stream)
92 92
93# Produce a statistics record
94if options.num_inversions > -1:
95 stream = stats.stats(stream,options.num_inversions)
96
97# Filter some records out 93# Filter some records out
98#def my_filter(record): 94#def my_filter(record):
99# if record.record_type == 'error' and record.type_name == 'inversion_end': 95# if record.record_type == 'error' and record.type_name == 'inversion_end':
@@ -102,13 +98,20 @@ if options.num_inversions > -1:
102# return True 98# return True
103#stream = filter(my_filter, stream) 99#stream = filter(my_filter, stream)
104 100
105# Output 101# Tee by the number of possible outputs
106if options.stdout is True and options.visualize is True: 102# This might cause a performance bottleneck that could be eliminated by
107 import itertools 103# checking how many we actually need :-)
108 stream1, stream2 = itertools.tee(stream,2) 104import itertools
105stream1, stream2, stream3 = itertools.tee(stream,3)
106
107# Call standard out printer
108if options.stdout is True:
109 stdout_printer.stdout_printer(stream1) 109 stdout_printer.stdout_printer(stream1)
110 viz.visualizer.visualizer(stream2) 110
111elif options.stdout is True: 111# Print G_EDF inversion statistics
112 stdout_printer.stdout_printer(stream) 112if options.num_inversions > -1:
113elif options.visualize is True: 113 gedf_inversion_stat_printer.gedf_inversion_stat_printer(stream2,options.num_inversions)
114 viz.visualizer.visualizer(stream) 114
115# Call visualizer
116if options.visualize is True:
117 viz.visualizer.visualizer(stream3)
diff --git a/unit_trace/stats.py b/unit_trace/gedf_inversion_stat_printer.py
index 4462ef1..c314389 100644
--- a/unit_trace/stats.py
+++ b/unit_trace/gedf_inversion_stat_printer.py
@@ -1,14 +1,14 @@
1############################################################################### 1###############################################################################
2# Description 2# Description
3############################################################################### 3###############################################################################
4# Compute and produce statistics 4# Compute and print G-EDF inversion statistics
5 5
6 6
7############################################################################### 7###############################################################################
8# Public Functions 8# Public Functions
9############################################################################### 9###############################################################################
10 10
11def stats(stream,num): 11def gedf_inversion_stat_printer(stream,num):
12 12
13 # State 13 # State
14 min_inversion = -1 14 min_inversion = -1
@@ -41,8 +41,6 @@ def stats(stream,num):
41 longest_inversions = _sort_longest_inversions( 41 longest_inversions = _sort_longest_inversions(
42 longest_inversions) 42 longest_inversions)
43 43
44 yield record
45
46 # We've seen all records. 44 # We've seen all records.
47 # Further update state 45 # Further update state
48 if num_inversions > 0: 46 if num_inversions > 0:
@@ -50,18 +48,32 @@ def stats(stream,num):
50 else: 48 else:
51 avg_inversion = 0 49 avg_inversion = 0
52 50
53 # Produce a meta type record with all our information. 51 # Print out our information
54 class Obj(object): pass 52 print "Num inversions: %d" % (num_inversions)
55 rec = Obj() 53 print "Min inversion: %d" % (min_inversion)
56 rec.record_type = "meta" 54 print "Max inversion: %d" % (max_inversion)
57 rec.type_name = "stats" 55 print "Avg inversion: %d" % (avg_inversion)
58 rec.num_inversions = num_inversions 56 for inv in longest_inversions:
59 rec.min_inversion = min_inversion 57 print ""
60 rec.max_inversion = max_inversion 58 print "Inversion record IDs: (%d, %d)" % (inv.inversion_start_id,
61 rec.avg_inversion = avg_inversion 59 inv.id)
62 longest_inversions = _sort_longest_inversions(longest_inversions) 60 print("Triggering Event IDs: (%d, %d)" %
63 rec.longest_inversions = longest_inversions 61 (inv.inversion_start_triggering_event_id,
64 yield rec 62 inv.triggering_event_id))
63 print "Time: %d" % (inv.job.inversion_end)
64 print "Duration: %d" % (
65 inv.job.inversion_end - inv.job.inversion_start)
66 print "Job: %d.%d" % (inv.job.pid,inv.job.job)
67 print "Deadline: %d" % (inv.job.deadline)
68 print "Eligible: ",
69 for job in inv.eligible:
70 print str(job) + " ",
71 print
72 print "On CPU: ",
73 for job in inv.on_cpu:
74 print str(job) + " ",
75 print ""
76
65 77
66def _sort_longest_inversions(longest_inversions): 78def _sort_longest_inversions(longest_inversions):
67 """ Sort longest inversions""" 79 """ Sort longest inversions"""
diff --git a/unit_trace/stdout_printer.py b/unit_trace/stdout_printer.py
index dd1e2bd..b8da9bf 100644
--- a/unit_trace/stdout_printer.py
+++ b/unit_trace/stdout_printer.py
@@ -68,13 +68,3 @@ def _print_inversion_end(record):
68 for job in record.on_cpu: 68 for job in record.on_cpu:
69 print str(job) + " ", 69 print str(job) + " ",
70 print #newline 70 print #newline
71
72def _print_stats(record):
73 print "Inversion statistics"
74 print "Num inversions: %d" % (record.num_inversions)
75 print "Min inversion: %d" % (record.min_inversion)
76 print "Max inversion: %d" % (record.max_inversion)
77 print "Avg inversion: %d" % (record.avg_inversion)
78 for inv in record.longest_inversions:
79 print ""
80 _print_inversion_end(inv)