-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRunDescribeMultiThread.py
More file actions
49 lines (40 loc) · 1.6 KB
/
Copy pathRunDescribeMultiThread.py
File metadata and controls
49 lines (40 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'''
Driver Program to run the DescribeMultiThread executable 10 times per
scheduling policy, and to store the results in a csv file:
RunDescribeAllTimes.txt
'''
#Policies:
# -b, --batch set policy to SCHED_BATCH
# -f, --fifo set policy to SCHED_FIFO
# -i, --idle set policy to SCHED_IDLE
# -o, --other set policy to SCHED_OTHER
# -r, --rr set policy to SCHED_RR (default)
import subprocess
from time import sleep
import os
import pandas as pd
policies = ('--batch','--fifo','--idle','--other','--rr')
min_priorities = (0,1,0,0,1)
data = pd.DataFrame()
for (policy,min_priority) in zip(policies,min_priorities):
sub_data = pd.DataFrame()
for i in range(10):
proc = subprocess.Popen(["./DescribeMultiThread"], stdout=subprocess.PIPE, shell=True)
pid = os.popen("sudo pidof -s ./DescribeMultiThread").read()
os.system(f"sudo chrt {policy} -p {min_priority} {pid}")
os.system(f"chrt -p {pid}")
proc.communicate()
if sub_data.empty:
sub_data = pd.read_csv("ThreadTimes.txt",header=None,index_col=0).T
else:
temp = pd.read_csv("ThreadTimes.txt",header=None,index_col=0).T
sub_data = pd.concat((sub_data,temp),sort=False)
old_cols = sub_data.columns
new_cols = [f"{i} {policy}" for i in old_cols]
cols_dict = {key:val for (key,val) in zip(old_cols,new_cols)}
sub_data.rename(columns=cols_dict,inplace=True)
if data.empty:
data = sub_data
else:
data=pd.concat((data,sub_data), axis = 1)
data.to_csv("RunDescribeAllTimes.txt")