message_scaling.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import os
  2. import subprocess
  3. SENDS = [2**i for i in range(18, 26)]
  4. FETCHES = 8192
  5. USERS = FETCHES
  6. THREADS = 48
  7. MAPS = 5
  8. RUNS = 10
  9. WARMUP = 0
  10. DATA_DIR = os.path.join(os.getcwd(), "data", "message-scaling")
  11. os.makedirs(DATA_DIR, exist_ok=True)
  12. SPARTA_DIR = os.path.join(os.getcwd(), "sparta")
  13. BASELINE_DIR = os.path.join(os.getcwd(), "baseline")
  14. BASELINE_FILE = os.path.join(DATA_DIR, f"baseline-{FETCHES}-{THREADS}.csv")
  15. SPARTA_FILE = os.path.join(DATA_DIR, f"sparta-{FETCHES}-{THREADS}-{MAPS}.csv")
  16. def sparta_cmd(sends):
  17. cmd = ["cargo", "run", "--release", "--",
  18. str(sends), str(FETCHES), str(THREADS), str(USERS), str(MAPS), "-r", str(RUNS), "-w", str(WARMUP)]
  19. result = subprocess.run(cmd, capture_output=True,
  20. text=True, cwd=SPARTA_DIR)
  21. print(result.stderr)
  22. return result.stdout
  23. def baseline_cmd(sends):
  24. cmd = ["cargo", "run", "--release", "--",
  25. str(sends), str(FETCHES), str(THREADS), "-r", str(RUNS), "-w", str(WARMUP)]
  26. result = subprocess.run(cmd, capture_output=True,
  27. text=True, cwd=BASELINE_DIR)
  28. return result.stdout
  29. for send in SENDS:
  30. print(send)
  31. with open(SPARTA_FILE, "a") as sparta_file:
  32. output = sparta_cmd(send)
  33. print("\tsparta:", output)
  34. sparta_file.write(output)
  35. with open(BASELINE_FILE, "a") as baseline_file:
  36. output = baseline_cmd(send)
  37. print("\tbaseline:", output)
  38. baseline_file.write(output)