message_scaling_legacy.py 2.0 KB

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