diff options
-rw-r--r-- | parse/dir_map.py | 35 | ||||
-rw-r--r-- | parse/tuple_table.py | 39 | ||||
-rwxr-xr-x | parse_exps.py | 3 |
3 files changed, 39 insertions, 38 deletions
diff --git a/parse/dir_map.py b/parse/dir_map.py index 319a5de..781607c 100644 --- a/parse/dir_map.py +++ b/parse/dir_map.py | |||
@@ -1,7 +1,6 @@ | |||
1 | import os | 1 | import os |
2 | 2 | ||
3 | from collections import defaultdict | 3 | from collections import defaultdict |
4 | from point import Type | ||
5 | 4 | ||
6 | class TreeNode(object): | 5 | class TreeNode(object): |
7 | def __init__(self, parent = None): | 6 | def __init__(self, parent = None): |
@@ -16,39 +15,16 @@ class DirMap(object): | |||
16 | val_strs += ["%s=%s" % (key, vals[key])] | 15 | val_strs += ["%s=%s" % (key, vals[key])] |
17 | return "%s.csv" % ("_".join(val_strs)) | 16 | return "%s.csv" % ("_".join(val_strs)) |
18 | 17 | ||
19 | def __init__(self, out_dir): | 18 | def __init__(self): |
20 | self.root = TreeNode(None) | 19 | self.root = TreeNode(None) |
21 | self.out_dir = out_dir | ||
22 | self.values = [] | 20 | self.values = [] |
23 | 21 | ||
24 | def debug_update_node(self, path, keys, value): | 22 | def add_value(self, path, value): |
25 | self.__update_node(path, keys, value) | ||
26 | |||
27 | def __update_node(self, path, keys, value): | ||
28 | node = self.root | 23 | node = self.root |
29 | |||
30 | path += [ self.to_csv(keys) ] | ||
31 | for p in path: | 24 | for p in path: |
32 | node = node.children[p] | 25 | node = node.children[p] |
33 | |||
34 | node.values += [value] | 26 | node.values += [value] |
35 | 27 | ||
36 | def add_point(self, vary, vary_value, keys, point): | ||
37 | for stat in point.get_stats(): | ||
38 | summary = point[stat] | ||
39 | |||
40 | for summary_type in Type: | ||
41 | measurement = summary[summary_type] | ||
42 | |||
43 | for base_type in Type: | ||
44 | if not base_type in measurement: | ||
45 | continue | ||
46 | # Ex: wcet/avg/max/vary-type/other-stuff.csv | ||
47 | path = [ stat, summary_type, base_type, "vary-%s" % vary ] | ||
48 | result = measurement[base_type] | ||
49 | |||
50 | self.__update_node(path, keys, (vary_value, result)) | ||
51 | |||
52 | def reduce(self): | 28 | def reduce(self): |
53 | def reduce2(node): | 29 | def reduce2(node): |
54 | for key in node.children.keys(): | 30 | for key in node.children.keys(): |
@@ -62,7 +38,7 @@ class DirMap(object): | |||
62 | 38 | ||
63 | reduce2(self.root) | 39 | reduce2(self.root) |
64 | 40 | ||
65 | def write(self): | 41 | def write(self, out_dir): |
66 | def write2(path, node): | 42 | def write2(path, node): |
67 | out_path = "/".join(path) | 43 | out_path = "/".join(path) |
68 | if node.values: | 44 | if node.values: |
@@ -78,8 +54,7 @@ class DirMap(object): | |||
78 | write2(path, child) | 54 | write2(path, child) |
79 | path.pop() | 55 | path.pop() |
80 | 56 | ||
81 | 57 | write2([out_dir], self.root) | |
82 | write2([self.out_dir], self.root) | ||
83 | 58 | ||
84 | 59 | ||
85 | def __str__(self): | 60 | def __str__(self): |
@@ -92,4 +67,4 @@ class DirMap(object): | |||
92 | ret += "%s/%s\n" % (header, key) | 67 | ret += "%s/%s\n" % (header, key) |
93 | ret += str2(child, level + 1) | 68 | ret += str2(child, level + 1) |
94 | return ret | 69 | return ret |
95 | return "%s\n%s" % (self.out_dir, str2(self.root, 1)) | 70 | return str2(self.root, 1) |
diff --git a/parse/tuple_table.py b/parse/tuple_table.py index 86006d2..a00e8ad 100644 --- a/parse/tuple_table.py +++ b/parse/tuple_table.py | |||
@@ -28,6 +28,8 @@ class ColMap(object): | |||
28 | return str(val).replace("_", "-").replace("=", "-") | 28 | return str(val).replace("_", "-").replace("=", "-") |
29 | vals = [] | 29 | vals = [] |
30 | for key in self.col_list: | 30 | for key in self.col_list: |
31 | if key not in kv: | ||
32 | continue | ||
31 | k, v = escape(key), escape(kv[key]) | 33 | k, v = escape(key), escape(kv[key]) |
32 | vals += ["%s=%s" % (k, v)] | 34 | vals += ["%s=%s" % (k, v)] |
33 | return "_".join(vals) | 35 | return "_".join(vals) |
@@ -116,8 +118,30 @@ class TupleTable(object): | |||
116 | with open(out_map, 'wc') as map_file: | 118 | with open(out_map, 'wc') as map_file: |
117 | pprint(result,stream=map_file, width=20) | 119 | pprint(result,stream=map_file, width=20) |
118 | 120 | ||
119 | def write_csvs(self, out_dir): | 121 | |
120 | dir_map = DirMap(out_dir) | 122 | def __add_to_dirmap(self, dir_map, variable, kv, point): |
123 | value = kv.pop(variable) | ||
124 | |||
125 | for stat in point.get_stats(): | ||
126 | summary = point[stat] | ||
127 | |||
128 | for summary_type in Type: | ||
129 | measurement = summary[summary_type] | ||
130 | |||
131 | for base_type in Type: | ||
132 | if not base_type in measurement: | ||
133 | continue | ||
134 | # Ex: release/num_tasks/measured-max/avg/x=5.csv | ||
135 | leaf = self.col_map.get_encoding(kv) + ".csv" | ||
136 | path = [ stat, variable, "taskset-" + base_type, summary_type, leaf ] | ||
137 | result = measurement[base_type] | ||
138 | |||
139 | dir_map.add_value(path, (value, result)) | ||
140 | |||
141 | kv[variable] = value | ||
142 | |||
143 | def to_dir_map(self): | ||
144 | dir_map = DirMap() | ||
121 | 145 | ||
122 | for key, point in self.table.iteritems(): | 146 | for key, point in self.table.iteritems(): |
123 | kv = self.col_map.get_map(key) | 147 | kv = self.col_map.get_map(key) |
@@ -128,12 +152,13 @@ class TupleTable(object): | |||
128 | try: | 152 | try: |
129 | float(val) | 153 | float(val) |
130 | except: | 154 | except: |
131 | # Only vary numbers. Otherwise, just have seperate lines | 155 | # Only vary numbers. Otherwise, just have seperate files |
132 | continue | 156 | continue |
133 | 157 | ||
134 | kv.pop(col) | 158 | self.__add_to_dirmap(dir_map, col, kv, point) |
135 | dir_map.add_point(col, val, kv, point) | ||
136 | kv[col] = val | ||
137 | 159 | ||
138 | dir_map.reduce() | 160 | dir_map.reduce() |
139 | dir_map.write() | 161 | return dir_map |
162 | |||
163 | def from_dir_map(dir_map): | ||
164 | pass | ||
diff --git a/parse_exps.py b/parse_exps.py index f7e1342..f8a1b98 100755 --- a/parse_exps.py +++ b/parse_exps.py | |||
@@ -127,7 +127,8 @@ def main(): | |||
127 | result_table.write_map(opts.out) | 127 | result_table.write_map(opts.out) |
128 | else: | 128 | else: |
129 | # Write out csv directories for all variable params | 129 | # Write out csv directories for all variable params |
130 | result_table.write_csvs(opts.out) | 130 | dir_map = result_table.to_dir_map() |
131 | dir_map.write(opts.out) | ||
131 | 132 | ||
132 | if __name__ == '__main__': | 133 | if __name__ == '__main__': |
133 | main() | 134 | main() |