-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-table.py
46 lines (40 loc) · 2.25 KB
/
generate-table.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
#!/usr/bin/env python3
import os
import subprocess
from tabulate import tabulate
REPETITIONS = 100
BENCHMARKS =\
[
("Lock", os.path.join("test", "examples", "de_liguoro_padovani", "lock.pat")),
("Future", os.path.join("test", "examples", "de_liguoro_padovani", "future.pat")),
("Account", os.path.join("test", "examples", "de_liguoro_padovani", "account.pat")),
("AccountF", os.path.join("test", "examples", "de_liguoro_padovani", "account_future.pat")),
("Master-Worker", os.path.join("test", "examples", "de_liguoro_padovani", "master_worker.pat")),
("Session Types", os.path.join("test", "examples", "de_liguoro_padovani", "sessions.pat")),
("Ping Pong", os.path.join("test", "examples", "savina", "ping_pong_strict.pat")),
("Thread Ring", os.path.join("test", "examples", "savina", "thread_ring.pat")),
("Counter", os.path.join("test", "examples", "savina", "count.pat")),
("K-Fork", os.path.join("test", "examples", "savina", "kfork.pat")),
("Fibonacci", os.path.join("test", "examples", "savina", "fib.pat")),
("Big", os.path.join("test", "examples", "savina", "big.pat")),
("Philosopher", os.path.join("test", "examples", "savina", "philosopher.pat")),
("Smokers", os.path.join("test", "examples", "savina", "cig_smok.pat")),
("Log Map", os.path.join("test", "examples", "savina", "log_map.pat")),
("Transaction", os.path.join("test", "examples", "savina", "banking.pat"))
]
# Tries to run in strict mode -- returns True if it works, False otherwise
def try_strict(path):
return subprocess.run(["./mbcheck", "--mode=strict", path],\
capture_output=True).returncode == 0
def run_benchmark(name, path):
print("Running example " + name)
is_strict = try_strict(path)
time = str(subprocess.run(["./mbcheck", "-b", str(REPETITIONS), path],\
capture_output=True, text=True).stdout)
return (name, is_strict, time)
def main():
print("Generating table -- this may take some time.")
results = [run_benchmark(name, path) for (name, path) in BENCHMARKS]
print(tabulate(results, headers=["Name", "Strict", "Time (ms)"], tablefmt='grid'))
if __name__ == "__main__":
main()