diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-11-26 16:02:48 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-11-26 16:02:48 -0500 |
commit | cb8db5d30ee769304c2c2b00f2a7d9bcb3c4098f (patch) | |
tree | c5352d84285af565d5246c3eb861ffba709761f1 /experiment | |
parent | 41c867480f1e20bd3b168258ed71450499ea6ccf (diff) |
Removed 2-step parse for scheduling statistics.
Diffstat (limited to 'experiment')
-rw-r--r-- | experiment/executable/executable.py | 10 | ||||
-rw-r--r-- | experiment/executable/ftcat.py | 4 | ||||
-rw-r--r-- | experiment/experiment.py | 10 | ||||
-rw-r--r-- | experiment/litmus_util.py | 12 |
4 files changed, 18 insertions, 18 deletions
diff --git a/experiment/executable/executable.py b/experiment/executable/executable.py index b964699..628f711 100644 --- a/experiment/executable/executable.py +++ b/experiment/executable/executable.py | |||
@@ -4,7 +4,7 @@ import signal | |||
4 | from ..litmus_util import is_executable | 4 | from ..litmus_util import is_executable |
5 | 5 | ||
6 | class Executable(object): | 6 | class Executable(object): |
7 | """Parent object that represents an executable for use in task-sets.""" | 7 | '''Parent object that represents an executable for use in task-sets.''' |
8 | 8 | ||
9 | def __init__(self, exec_file, extra_args=None, stdout_file = None, stderr_file = None): | 9 | def __init__(self, exec_file, extra_args=None, stdout_file = None, stderr_file = None): |
10 | self.exec_file = exec_file | 10 | self.exec_file = exec_file |
@@ -47,7 +47,7 @@ class Executable(object): | |||
47 | return " ".join(self.__get_full_command()) | 47 | return " ".join(self.__get_full_command()) |
48 | 48 | ||
49 | def execute(self): | 49 | def execute(self): |
50 | """Execute the binary.""" | 50 | '''Execute the binary.''' |
51 | full_command = self.__get_full_command() | 51 | full_command = self.__get_full_command() |
52 | self.sp = subprocess.Popen(full_command, stdout=self.stdout_file, | 52 | self.sp = subprocess.Popen(full_command, stdout=self.stdout_file, |
53 | stderr=self.stderr_file, cwd=self.cwd) | 53 | stderr=self.stderr_file, cwd=self.cwd) |
@@ -59,15 +59,15 @@ class Executable(object): | |||
59 | self.sp.send_signal(signal.SIGINT) | 59 | self.sp.send_signal(signal.SIGINT) |
60 | 60 | ||
61 | def terminate(self): | 61 | def terminate(self): |
62 | """Send the terminate signal to the binary.""" | 62 | '''Send the terminate signal to the binary.''' |
63 | self.sp.terminate() | 63 | self.sp.terminate() |
64 | 64 | ||
65 | def wait(self): | 65 | def wait(self): |
66 | """Wait until the executable is finished, checking return code. | 66 | '''Wait until the executable is finished, checking return code. |
67 | 67 | ||
68 | If the exit status is non-zero, raise an exception. | 68 | If the exit status is non-zero, raise an exception. |
69 | 69 | ||
70 | """ | 70 | ''' |
71 | 71 | ||
72 | self.sp.wait() | 72 | self.sp.wait() |
73 | if self.sp.returncode != 0: | 73 | if self.sp.returncode != 0: |
diff --git a/experiment/executable/ftcat.py b/experiment/executable/ftcat.py index 9966312..5da8fa7 100644 --- a/experiment/executable/ftcat.py +++ b/experiment/executable/ftcat.py | |||
@@ -4,10 +4,10 @@ import stat | |||
4 | from executable import Executable | 4 | from executable import Executable |
5 | 5 | ||
6 | class FTcat(Executable): | 6 | class FTcat(Executable): |
7 | """Used to wrap the ftcat binary in the Experiment object.""" | 7 | '''Used to wrap the ftcat binary in the Experiment object.''' |
8 | 8 | ||
9 | def __init__(self, ft_cat_bin, stdout_file, stderr_file, dev, events, cpu=None): | 9 | def __init__(self, ft_cat_bin, stdout_file, stderr_file, dev, events, cpu=None): |
10 | """Extends the Executable initializer method with ftcat attributes.""" | 10 | '''Extends the Executable initializer method with ftcat attributes.''' |
11 | 11 | ||
12 | # hack to run FTCat at higher priority | 12 | # hack to run FTCat at higher priority |
13 | chrt_bin = '/usr/bin/chrt' | 13 | chrt_bin = '/usr/bin/chrt' |
diff --git a/experiment/experiment.py b/experiment/experiment.py index deb4ff2..4bd47c6 100644 --- a/experiment/experiment.py +++ b/experiment/experiment.py | |||
@@ -5,19 +5,19 @@ from operator import methodcaller | |||
5 | from tracer import SchedTracer, LogTracer, PerfTracer, LinuxTracer, OverheadTracer | 5 | from tracer import SchedTracer, LogTracer, PerfTracer, LinuxTracer, OverheadTracer |
6 | 6 | ||
7 | class ExperimentException(Exception): | 7 | class ExperimentException(Exception): |
8 | """Used to indicate when there are problems with an experiment.""" | 8 | '''Used to indicate when there are problems with an experiment.''' |
9 | def __init__(self, name): | 9 | def __init__(self, name): |
10 | self.name = name | 10 | self.name = name |
11 | 11 | ||
12 | 12 | ||
13 | class ExperimentDone(ExperimentException): | 13 | class ExperimentDone(ExperimentException): |
14 | """Raised when an experiment looks like it's been run already.""" | 14 | '''Raised when an experiment looks like it's been run already.''' |
15 | def __str__(self): | 15 | def __str__(self): |
16 | return "Experiment finished already: %d" % self.name | 16 | return "Experiment finished already: %d" % self.name |
17 | 17 | ||
18 | 18 | ||
19 | class ExperimentInterrupted(ExperimentException): | 19 | class ExperimentInterrupted(ExperimentException): |
20 | """Raised when an experiment appears to be interrupted (partial results).""" | 20 | '''Raised when an experiment appears to be interrupted (partial results).''' |
21 | def __str__(self): | 21 | def __str__(self): |
22 | return "Experiment was interrupted in progress: %d" % self.name | 22 | return "Experiment was interrupted in progress: %d" % self.name |
23 | 23 | ||
@@ -28,11 +28,11 @@ class ExperimentFailed(ExperimentException): | |||
28 | 28 | ||
29 | 29 | ||
30 | class Experiment(object): | 30 | class Experiment(object): |
31 | """Execute one task-set and save the results. Experiments have unique IDs.""" | 31 | '''Execute one task-set and save the results. Experiments have unique IDs.''' |
32 | INTERRUPTED_DIR = ".interrupted" | 32 | INTERRUPTED_DIR = ".interrupted" |
33 | 33 | ||
34 | def __init__(self, name, scheduler, working_dir, finished_dir, proc_entries, executables): | 34 | def __init__(self, name, scheduler, working_dir, finished_dir, proc_entries, executables): |
35 | """Run an experiment, optionally wrapped in tracing.""" | 35 | '''Run an experiment, optionally wrapped in tracing.''' |
36 | 36 | ||
37 | self.name = name | 37 | self.name = name |
38 | self.scheduler = scheduler | 38 | self.scheduler = scheduler |
diff --git a/experiment/litmus_util.py b/experiment/litmus_util.py index 42d3e5f..fb2b341 100644 --- a/experiment/litmus_util.py +++ b/experiment/litmus_util.py | |||
@@ -6,7 +6,7 @@ import stat | |||
6 | import config.config as conf | 6 | import config.config as conf |
7 | 7 | ||
8 | def num_cpus(): | 8 | def num_cpus(): |
9 | """Return the number of CPUs in the system.""" | 9 | '''Return the number of CPUs in the system.''' |
10 | 10 | ||
11 | lnx_re = re.compile(r'^(processor|online)') | 11 | lnx_re = re.compile(r'^(processor|online)') |
12 | cpus = 0 | 12 | cpus = 0 |
@@ -18,9 +18,9 @@ def num_cpus(): | |||
18 | return cpus | 18 | return cpus |
19 | 19 | ||
20 | def cpu_freq(): | 20 | def cpu_freq(): |
21 | """ | 21 | ''' |
22 | The frequency (in MHz) of the CPU. | 22 | The frequency (in MHz) of the CPU. |
23 | """ | 23 | ''' |
24 | reg = re.compile(r'^cpu MHz\s*:\s*(\d+)', re.M) | 24 | reg = re.compile(r'^cpu MHz\s*:\s*(\d+)', re.M) |
25 | with open('/proc/cpuinfo', 'r') as f: | 25 | with open('/proc/cpuinfo', 'r') as f: |
26 | data = f.read() | 26 | data = f.read() |
@@ -31,12 +31,12 @@ def cpu_freq(): | |||
31 | return int(match.group(1)) | 31 | return int(match.group(1)) |
32 | 32 | ||
33 | def switch_scheduler(switch_to_in): | 33 | def switch_scheduler(switch_to_in): |
34 | """Switch the scheduler to whatever is passed in. | 34 | '''Switch the scheduler to whatever is passed in. |
35 | 35 | ||
36 | This methods sleeps for two seconds to give Linux the chance to execute | 36 | This methods sleeps for two seconds to give Linux the chance to execute |
37 | schedule switching code. Raises an exception if the switch does not work. | 37 | schedule switching code. Raises an exception if the switch does not work. |
38 | 38 | ||
39 | """ | 39 | ''' |
40 | 40 | ||
41 | switch_to = str(switch_to_in).strip() | 41 | switch_to = str(switch_to_in).strip() |
42 | 42 | ||
@@ -57,7 +57,7 @@ def uname_matches(reg): | |||
57 | return bool( re.match(reg, data) ) | 57 | return bool( re.match(reg, data) ) |
58 | 58 | ||
59 | def is_executable(fname): | 59 | def is_executable(fname): |
60 | """Return whether the file passed in is executable""" | 60 | '''Return whether the file passed in is executable''' |
61 | mode = os.stat(fname)[stat.ST_MODE] | 61 | mode = os.stat(fname)[stat.ST_MODE] |
62 | return mode & stat.S_IXUSR and mode & stat.S_IRUSR | 62 | return mode & stat.S_IXUSR and mode & stat.S_IRUSR |
63 | 63 | ||