user_and_message_scaling.py 2.0 KB

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