user_and_message_scaling.py 1.4 KB

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