-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunGCP.py
56 lines (48 loc) · 1.73 KB
/
runGCP.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
from subprocess import Popen, PIPE, STDOUT
import subprocess
import logging
import sys
import threading
nrExperiments = 40
protocolName = "gcp"
nodes = 0 # Number of nodes
time = 600 # Number of seconds to run the experiment
batchSize = 1 #62500 for 500KB of transactions sized 8B each, Narwhal's batch size
crashes = 0
host = "192.168.0.115"
port = 8088
for i in range(nrExperiments):
nodes = nodes + 5
# crashes = (nodes-1) // 3
# crashes = nodes // 4
# batchSize = batchSize + 50
# Command to run the Haskell program using cabal
command = [
"cabal", "v2-run", protocolName, "--",
"--replicas", str(nodes),
"--crashes", str(crashes),
"--time", str(time),
"--batchSize", str(batchSize),
"--host", str(host),
"--port", str(port),
"-m", "master"
]
# Setup logger for the current experiment
# logger = logging.basicConfig(filename=f"output_{i}.log", level=logging.INFO)
logger = logging.getLogger(f"experiment_{i}")
logger.setLevel(logging.INFO)
process = Popen(command, stdout=PIPE, stderr=STDOUT)
with process.stdout:
log_file = f"output_{i}.log"
log_format = "|%(levelname)s| : [%(filename)s]--[%(funcName)s] : %(message)s"
formatter = logging.Formatter(log_format)
# create file handler and set the formatter
file_handler = logging.FileHandler(log_file)
file_handler.setFormatter(formatter)
# add handler to the logger
logger.addHandler(file_handler)
for line in iter(process.stdout.readline, b''): # b'\n'-separated lines
logger.info('%r', line)
exitcode = process.wait() # 0 means success
if exitcode == 0:
print(f"processed experiment {i}")