message_scaling.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import os
  2. import subprocess
  3. SENDS = [2**i for i in range(20, 30)]
  4. FETCHES = 50000
  5. USERS = int(FETCHES / 2)
  6. THREADS = 8
  7. MAPS = 4
  8. RUNS = 1
  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)]
  19. result = subprocess.run(cmd, capture_output=True,
  20. text=True, cwd=SPARTA_DIR)
  21. return result.stdout
  22. def baseline_cmd(sends):
  23. cmd = ["cargo", "run", "--release", "--",
  24. str(sends), str(FETCHES), str(THREADS)]
  25. result = subprocess.run(cmd, capture_output=True,
  26. text=True, cwd=BASELINE_DIR)
  27. return result.stdout
  28. for send in SENDS:
  29. print(send)
  30. with open(SPARTA_FILE, "a") as sparta_file:
  31. output = sparta_cmd(send)
  32. print("\tsparta:", output)
  33. sparta_file.write(output)
  34. with open(BASELINE_FILE, "a") as baseline_file:
  35. output = baseline_cmd(send)
  36. print("\tbaseline:", output)
  37. baseline_file.write(output)