Commit eabe38d4 authored by Weixin Deng's avatar Weixin Deng
Browse files

(WIP) Add goodput script

parent cbcc77fd
*.txt filter=lfs diff=lfs merge=lfs -text
import argparse
import dataclasses
import subprocess
import pathlib
from datetime import datetime
import pytz
@dataclasses.dataclass(frozen=True)
class ClientConfig:
num_ports: int
num_backends: int
data_size: int
def generate_cmd(config: ClientConfig):
cmd = [
"go run ../src/service.go",
"-client",
'-addr "10.0.0.1"',
f"-numPorts {config.num_ports}",
f"-numBackends {config.num_backends}",
f"-dataSize {config.data_size}",
f"-serverDelay 0",
f"-repeat 10",
]
return " ".join(cmd)
def run_client(config: ClientConfig):
cmd = generate_cmd(config)
output = subprocess.check_output(
cmd, stderr=subprocess.STDOUT, text=True, shell=True
)
output_dir = pathlib.Path(__file__).resolve().parents[1] / "data"
local_time = datetime.now(pytz.timezone("US/Pacific"))
output_file = f"{output_dir}/{local_time:%y%m%d-%H%M%S}.txt"
with open(output_file, "w") as file:
file.write(output)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--num-ports-enum", nargs="+", type=int)
parser.add_argument("--num-backends-enum", nargs="+", type=int)
parser.add_argument("--data-size-enum", nargs="+", type=int)
args = parser.parse_args()
for num_ports in args.num_ports_enum:
for num_backends in args.num_backends_enum:
for data_size in args.data_size_enum:
config = ClientConfig(
num_ports=num_ports, num_backends=num_backends, data_size=data_size
)
run_client(config)
if __name__ == "__main__":
main()
python3 goodput.py \
--num-ports-enum 1 2 4 8 16 \
--num-backends-enum 1 2 4 8 \
--data-size-enum 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment