extract_data_bs.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import sys
  2. import re
  3. def extract_binary_search_data(output):
  4. bytes_sent_pattern = r"BINARY SEARCH =====\n\d+ messages sent\n(\d+) message bytes sent"
  5. wall_clock_pattern = r"BINARY SEARCH =====\n\d+ messages sent\n\d+ message bytes sent\n\d+ Lamport clock \(latencies\)\n\d+ local AES operations\n(\d+) milliseconds wall clock time"
  6. bytes_sent_matches = re.findall(bytes_sent_pattern, output)
  7. wall_clock_matches = re.findall(wall_clock_pattern, output)
  8. bytes_sent = [int(match) for match in bytes_sent_matches]
  9. wall_clock_time = [int(match) for match in wall_clock_matches]
  10. return bytes_sent, wall_clock_time
  11. if __name__ == "__main__":
  12. if len(sys.argv) != 2:
  13. print("Usage: python script.py <input_file>")
  14. sys.exit(1)
  15. input_file = sys.argv[1]
  16. try:
  17. with open(input_file, 'r') as f:
  18. output = f.read()
  19. except FileNotFoundError:
  20. print(f"File not found: {input_file}")
  21. sys.exit(1)
  22. bytes_sent, wall_clock_time = extract_binary_search_data(output)
  23. max_bytes_sent = max(bytes_sent)
  24. max_wall_clock_time = max(wall_clock_time)
  25. print(f"{max_bytes_sent}")
  26. print(f"{max_wall_clock_time}")