From 7c09ec981c6e06af2e62d67a609eb53728267954 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Thu, 27 Sep 2012 19:03:22 -0400 Subject: Added script to parse directory data, create CSVs for every chagned value. This change also makes SchedTrace and OverheadTrace events configurable. --- parse/ft.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 parse/ft.py (limited to 'parse/ft.py') diff --git a/parse/ft.py b/parse/ft.py new file mode 100644 index 0000000..9837898 --- /dev/null +++ b/parse/ft.py @@ -0,0 +1,60 @@ +import config.config as conf +import os +import re +import shutil as sh +import subprocess + +from point import Measurement,Type + +def get_ft_output(data_dir, out_dir): + bin_file = conf.FILES['ft_data'] + "$" + bins = [f for f in os.listdir(data_dir) if re.match(bin_file, f)] + + FT_DATA_NAME = "scheduler=x-ft" + output_file = "{}/out-ft".format(out_dir) + + if os.path.isfile(output_file): + print("ft-output already exists for %s" % data_dir) + return output_file + + if len(bins) != 0: + err_file = open("%s/err-ft" % out_dir, 'w') + # Need to make a copy of the original data file so scripts can change it + sh.copyfile("{}/{}".format(data_dir, bins[0]), + "{}/{}".format(out_dir, FT_DATA_NAME)) + + subprocess.call([conf.BINS['sort'], FT_DATA_NAME], + cwd=out_dir, stderr=err_file, stdout=err_file) + subprocess.call([conf.BINS['split'], FT_DATA_NAME], + cwd=out_dir, stderr=err_file, stdout=err_file) + + # Previous subprocesses just spit out all these intermediate files + bins = [f for f in os.listdir(out_dir) if re.match(".*overhead=.*bin", f)] + bins = [f for f in bins if os.stat("%s/%s"%(out_dir, f)).st_size] + + # Analyze will summarize those + cmd_arr = [conf.BINS['analyze']] + cmd_arr.extend(bins) + with open(output_file, "w") as f: + subprocess.call(cmd_arr, cwd=out_dir, stdout=f, stderr=err_file) + else: + return None + return output_file + +def get_ft_data(data_file, result, overheads): + rstr = r",(?:\s+[^\s]+){3}.*?([\d\.]+).*?([\d\.]+),(?:\s+[^\s]+){3}.*?([\d\.]+)" + + with open(data_file) as f: + data = f.read() + + for ovh in overheads: + measure = Measurement("%s-%s" % (data_file, ovh)) + vals = re.findall(".*{}".format(ovh) + rstr, data); + if len(vals) != 0: + vals = vals[0] + measure[Type.Max] = float(vals[0]) + measure[Type.Avg] = float(vals[1]) + measure[Type.Var] = float(vals[2]) + result[ovh] = measure + + return result -- cgit v1.2.2