diff options
Diffstat (limited to 'experiment/litmus_util.py')
| -rw-r--r-- | experiment/litmus_util.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/experiment/litmus_util.py b/experiment/litmus_util.py index cde0bca..42d3e5f 100644 --- a/experiment/litmus_util.py +++ b/experiment/litmus_util.py | |||
| @@ -17,6 +17,19 @@ def num_cpus(): | |||
| 17 | cpus += 1 | 17 | cpus += 1 |
| 18 | return cpus | 18 | return cpus |
| 19 | 19 | ||
| 20 | def cpu_freq(): | ||
| 21 | """ | ||
| 22 | The frequency (in MHz) of the CPU. | ||
| 23 | """ | ||
| 24 | reg = re.compile(r'^cpu MHz\s*:\s*(\d+)', re.M) | ||
| 25 | with open('/proc/cpuinfo', 'r') as f: | ||
| 26 | data = f.read() | ||
| 27 | |||
| 28 | match = re.search(reg, data) | ||
| 29 | if not match: | ||
| 30 | raise Exception("Cannot parse CPU frequency!") | ||
| 31 | return int(match.group(1)) | ||
| 32 | |||
| 20 | def switch_scheduler(switch_to_in): | 33 | def switch_scheduler(switch_to_in): |
| 21 | """Switch the scheduler to whatever is passed in. | 34 | """Switch the scheduler to whatever is passed in. |
| 22 | 35 | ||
