diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-27 19:03:22 -0400 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-09-27 19:03:22 -0400 |
| commit | 7c09ec981c6e06af2e62d67a609eb53728267954 (patch) | |
| tree | 76a93db7cadc452ac70eabbd52fdd87ed5fd54c4 /parse/ft.py | |
| parent | 5554e053e9f3d5f7987d3f1d889802b211af8eab (diff) | |
Added script to parse directory data, create CSVs for every chagned value.
This change also makes SchedTrace and OverheadTrace events configurable.
Diffstat (limited to 'parse/ft.py')
| -rw-r--r-- | parse/ft.py | 60 |
1 files changed, 60 insertions, 0 deletions
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 @@ | |||
| 1 | import config.config as conf | ||
| 2 | import os | ||
| 3 | import re | ||
| 4 | import shutil as sh | ||
| 5 | import subprocess | ||
| 6 | |||
| 7 | from point import Measurement,Type | ||
| 8 | |||
| 9 | def get_ft_output(data_dir, out_dir): | ||
| 10 | bin_file = conf.FILES['ft_data'] + "$" | ||
| 11 | bins = [f for f in os.listdir(data_dir) if re.match(bin_file, f)] | ||
| 12 | |||
| 13 | FT_DATA_NAME = "scheduler=x-ft" | ||
| 14 | output_file = "{}/out-ft".format(out_dir) | ||
| 15 | |||
| 16 | if os.path.isfile(output_file): | ||
| 17 | print("ft-output already exists for %s" % data_dir) | ||
| 18 | return output_file | ||
| 19 | |||
| 20 | if len(bins) != 0: | ||
| 21 | err_file = open("%s/err-ft" % out_dir, 'w') | ||
| 22 | # Need to make a copy of the original data file so scripts can change it | ||
| 23 | sh.copyfile("{}/{}".format(data_dir, bins[0]), | ||
| 24 | "{}/{}".format(out_dir, FT_DATA_NAME)) | ||
| 25 | |||
| 26 | subprocess.call([conf.BINS['sort'], FT_DATA_NAME], | ||
| 27 | cwd=out_dir, stderr=err_file, stdout=err_file) | ||
| 28 | subprocess.call([conf.BINS['split'], FT_DATA_NAME], | ||
| 29 | cwd=out_dir, stderr=err_file, stdout=err_file) | ||
| 30 | |||
| 31 | # Previous subprocesses just spit out all these intermediate files | ||
| 32 | bins = [f for f in os.listdir(out_dir) if re.match(".*overhead=.*bin", f)] | ||
| 33 | bins = [f for f in bins if os.stat("%s/%s"%(out_dir, f)).st_size] | ||
| 34 | |||
| 35 | # Analyze will summarize those | ||
| 36 | cmd_arr = [conf.BINS['analyze']] | ||
| 37 | cmd_arr.extend(bins) | ||
| 38 | with open(output_file, "w") as f: | ||
| 39 | subprocess.call(cmd_arr, cwd=out_dir, stdout=f, stderr=err_file) | ||
| 40 | else: | ||
| 41 | return None | ||
| 42 | return output_file | ||
| 43 | |||
| 44 | def get_ft_data(data_file, result, overheads): | ||
| 45 | rstr = r",(?:\s+[^\s]+){3}.*?([\d\.]+).*?([\d\.]+),(?:\s+[^\s]+){3}.*?([\d\.]+)" | ||
| 46 | |||
| 47 | with open(data_file) as f: | ||
| 48 | data = f.read() | ||
| 49 | |||
| 50 | for ovh in overheads: | ||
| 51 | measure = Measurement("%s-%s" % (data_file, ovh)) | ||
| 52 | vals = re.findall(".*{}".format(ovh) + rstr, data); | ||
| 53 | if len(vals) != 0: | ||
| 54 | vals = vals[0] | ||
| 55 | measure[Type.Max] = float(vals[0]) | ||
| 56 | measure[Type.Avg] = float(vals[1]) | ||
| 57 | measure[Type.Var] = float(vals[2]) | ||
| 58 | result[ovh] = measure | ||
| 59 | |||
| 60 | return result | ||
