From e49fb36048adf57c6cd7e65c59af37ad81fba35c Mon Sep 17 00:00:00 2001 From: Andrea Bastoni Date: Sun, 21 Mar 2010 16:46:51 -0400 Subject: Compact csv result files for multiple WSS in single result file hard_pm_plugin=GSN-EDF_dist=uni_light_wss=1024_ovd=preemption.csv hard_pm_plugin=GSN-EDF_dist=uni_light_wss=2048_ovd=preemption.csv hard_pm_plugin=GSN-EDF_dist=uni_light_wss=3072_ovd=preemption.csv => hard_pm_plugin=GSN-EDF_dist=uni_light_wss=1024,2048,3072_ovd=preemption.csv --- compact_pm_ovd.py | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 compact_pm_ovd.py diff --git a/compact_pm_ovd.py b/compact_pm_ovd.py new file mode 100755 index 0000000..5024d61 --- /dev/null +++ b/compact_pm_ovd.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python + +from os.path import splitext, basename, dirname +from optparse import OptionParser + +def decode(name): + params = {} + parts = name.split('_') + for p in parts: + kv = p.split('=') + k = kv[0] + v = kv[1] if len(kv) > 1 else None + params[k] = v + return params + + +def build_name(dirname, conf, wss_list): + if dirname == '': + dirname = '.' + outname = dirname + '/' + if 'hard' in conf: + outname += 'hard' + else: + outname += 'soft' + outname += '_pm_plugin=' + conf['plugin'] + '_dist=' + conf['dist'] + # atm we use only uniform for PM (we also use only light, but...) + if 'light' in conf: + outname += '_light' + elif 'medium' in conf: + outname += '_medium' + elif 'heavy' in conf: + outname += '_heavy' + + outname += '_wss=' + for wss in wss_list: + if wss != wss_list[len(wss_list) - 1]: + outname += str(wss) + ',' + else: + outname += str(wss) + outname += '_ovd=' + conf['ovd'] + '.csv' + return outname + + +class WSSCompactor(): + def __init__(self): + self.ovhead_table = {} + self.wss_list = [] + + def add_wss(self, wss): + self.wss_list.append(int(wss)) + + def read_csv(self, datafile): + csvf = open(datafile, 'r') + # csvf format is: tss, max, avg + for line in csvf: + tmp = line.split(', ') + if tmp[0] in self.ovhead_table.keys(): + self.ovhead_table[tmp[0]] += [tmp[1], tmp[2].rstrip('\n')] + else: + self.ovhead_table[tmp[0]] = [tmp[1], tmp[2].rstrip('\n')] + csvf.close() + + def write_csv(self, dirname, conf): + self.wss_list.sort() + outname = build_name(dirname, conf, self.wss_list) + csvf = open(outname, 'w') + csvf.write('# preemption and migration overhead for ' + \ + conf['plugin'] + '\n') + + wstr = '# tssize, ' + for wss in self.wss_list: + wstr += 'wss=' + str(wss) + ':(max, avg), ' + csvf.write(wstr[0:-2] + '\n') + + tkeys = self.ovhead_table.keys() + for i in range(0,len(tkeys)): + tkeys[i] = int(tkeys[i]) + tkeys.sort() + + for key in tkeys: + wstr = str(key) + ', ' + for value in self.ovhead_table[str(key)]: + wstr += value + ', ' + wstr = wstr[0:-2] + csvf.write(wstr + '\n') + + csvf.close() + +def main(args): + wsscmpctr = WSSCompactor() + for datafile in args: + bname = basename(datafile) + fname, ext = splitext(bname) + if ext != '.csv': + self.err("Warning: '%s' doesn't look like a CSV file." + % bname) + conf = decode(fname) + wsscmpctr.add_wss(conf['wss']) + wsscmpctr.read_csv(datafile) + + # assume all files in same directory and same kind of overheads + wsscmpctr.write_csv(dirname(datafile), conf) + +if __name__ == "__main__": + usage = "Usage: %prog list-of-file" + parser = OptionParser(usage=usage) + (options, args) = parser.parse_args() + if len(args) < 1: + parser.error("Argument missing") + sys.exit(-1) + main(args) -- cgit v1.2.2