message_scaling.py 2.1 KB

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