-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiments.py
62 lines (52 loc) · 1.39 KB
/
experiments.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
"""Run a set of experiments with different kernels and delays."""
from pathlib import Path
import subprocess
from enum import Enum, IntEnum
class KernelType(Enum):
"""Defines the SMOG kernel types."""
LINEAR = "l"
RANDOM = "r"
WRITE = "w"
POINTERCHASE = "p"
COLD = "c"
DIRTY = "d"
class Delay(IntEnum):
"""Defines the configrued SMOG delays."""
NONE = 0
LONG = 1000
SHORT = 100
def smog(kernels: list[KernelType], delay: int, csv_file: Path):
"""Run the smog program with the given configuration."""
binary = "./smog"
timeout = 10
args = [
binary,
"-k",
*[k.value for k in kernels],
"-t",
str(len(kernels)),
"-d",
str(delay),
"-c",
str(csv_file),
]
print(f'+{" ".join(args)}')
try:
subprocess.call(args, timeout=timeout)
except subprocess.TimeoutExpired:
pass
def main():
"""Run a set of experiments."""
data_base = Path("data")
data_base.mkdir(exist_ok=True, parents=True)
i = 0
t = len(KernelType) * len(Delay)
for kernel in KernelType:
for delay in map(int, Delay):
i = i + 1
print(f'[{i}/{t}]', end='')
kernels = [kernel] * 4
csv_path = data_base / f"{kernel.name.lower()}_{delay}.csv"
smog(kernels, delay, csv_path)
if __name__ == "__main__":
main()