From e948e4b6a6cf1efd8d1f3d3359b1ad9891b3babc Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Wed, 17 Apr 2013 13:56:55 -0400 Subject: Cleaned up sched_trace output and code. --- parse/sched.py | 46 ++++++++++++++++++++++++++------------------ run/executable/executable.py | 5 +++-- run/tracer.py | 4 ++-- run_exps.py | 3 +-- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/parse/sched.py b/parse/sched.py index 1213f0d..13c7ca2 100644 --- a/parse/sched.py +++ b/parse/sched.py @@ -2,7 +2,6 @@ import config.config as conf import os import re import struct -import sys import subprocess from collections import defaultdict,namedtuple @@ -92,7 +91,12 @@ def make_iterator(fname): continue obj = rdata.clazz(*values) - yield (obj, rdata.method) + + if obj.job != 1: + yield (obj, rdata.method) + else: + # Results from the first job are nonsense + pass def read_data(task_dict, fnames): '''Read records from @fnames and store per-pid stats in @task_dict.''' @@ -147,32 +151,35 @@ register_record('ReleaseRecord', 3, process_release, 'QQ', ['release', 'when']) register_record('ParamRecord', 2, process_param, 'IIIcc2x', ['wcet','period','phase','partition', 'task_class']) -def extract_sched_data(result, data_dir, work_dir): +def create_task_dict(data_dir, work_dir = None): + '''Parse sched trace files''' bin_files = conf.FILES['sched_data'].format(".*") output_file = "%s/out-st" % work_dir - bins = ["%s/%s" % (data_dir,f) for f in os.listdir(data_dir) if re.match(bin_files, f)] - if not len(bins): - return + task_dict = defaultdict(lambda : + TaskData(None, 1, TimeTracker(), TimeTracker())) + + bin_names = [f for f in os.listdir(data_dir) if re.match(bin_files, f)] + if not len(bin_names): + return task_dict # Save an in-english version of the data for debugging # This is optional and will only be done if 'st_show' is in PATH if conf.BINS['st_show']: cmd_arr = [conf.BINS['st_show']] - cmd_arr.extend(bins) + cmd_arr.extend(bin_names) with open(output_file, "w") as f: - print("calling %s" % cmd_arr) subprocess.call(cmd_arr, cwd=data_dir, stdout=f) - task_dict = defaultdict(lambda : - TaskData(0, 0, TimeTracker(), TimeTracker())) - # Gather per-task values - read_data(task_dict, bins) + bin_paths = ["%s/%s" % (data_dir,f) for f in bin_names] + read_data(task_dict, bin_paths) - stat_data = {"avg-tard" : [], "max-tard" : [], - "avg-block" : [], "max-block" : [], - "miss-ratio" : []} + return task_dict + +def extract_sched_data(result, data_dir, work_dir): + task_dict = create_task_dict(data_dir, work_dir) + stat_data = defaultdict(list) # Group per-task values for tdata in task_dict.itervalues(): @@ -181,18 +188,19 @@ def extract_sched_data(result, data_dir, work_dir): continue miss_ratio = float(tdata.misses.num) / tdata.jobs + stat_data["miss-ratio"].append(float(tdata.misses.num) / tdata.jobs) + + stat_data["max-tard" ].append(tdata.misses.max / tdata.params.wcet) # Scale average down to account for jobs with 0 tardiness avg_tard = tdata.misses.avg * miss_ratio - - stat_data["miss-ratio"].append(miss_ratio) stat_data["avg-tard" ].append(avg_tard / tdata.params.wcet) - stat_data["max-tard" ].append(tdata.misses.max / tdata.params.wcet) + stat_data["avg-block" ].append(tdata.blocks.avg / NSEC_PER_MSEC) stat_data["max-block" ].append(tdata.blocks.max / NSEC_PER_MSEC) # Summarize value groups for name, data in stat_data.iteritems(): - if not data: + if not data or not sum(data): continue result[name] = Measurement(str(name)).from_array(data) diff --git a/run/executable/executable.py b/run/executable/executable.py index 263e305..e6f2003 100644 --- a/run/executable/executable.py +++ b/run/executable/executable.py @@ -6,9 +6,10 @@ from common import get_executable class Executable(object): '''Parent object that represents an executable for use in task-sets.''' - def __init__(self, exec_file, extra_args=None, stdout_file = None, stderr_file = None): + def __init__(self, exec_file, extra_args=None, stdout_file = None, + stderr_file = None, cwd = None): self.exec_file = get_executable(exec_file) - self.cwd = None + self.cwd = cwd self.stdout_file = stdout_file self.stderr_file = stderr_file self.sp = None diff --git a/run/tracer.py b/run/tracer.py index 6e1d05c..5e92a74 100644 --- a/run/tracer.py +++ b/run/tracer.py @@ -38,8 +38,8 @@ class LinuxTracer(Tracer): stdout = open('%s/trace-cmd-stdout.txt' % self.output_dir, 'w') stderr = open('%s/trace-cmd-stderr.txt' % self.output_dir, 'w') - execute = Executable(conf.BINS['trace-cmd'], extra_args, stdout, stderr) - execute.cwd = output_dir + execute = Executable(conf.BINS['trace-cmd'], extra_args, + stdout, stderr, output_dir) self.bins.append(execute) @staticmethod diff --git a/run_exps.py b/run_exps.py index 6531415..905d033 100755 --- a/run_exps.py +++ b/run_exps.py @@ -197,9 +197,8 @@ def run_parameter(exp_dir, out_dir, params, param_name): script = com.get_executable(script_name, cwd=exp_dir) out = open('%s/%s-out.txt' % (out_dir, param_name), 'w') - prog = Executable(script, script_params, + prog = Executable(script, script_params, cwd=out_dir, stderr_file=out, stdout_file=out) - prog.cwd = out_dir prog.execute() prog.wait() -- cgit v1.2.2