extract_data_from_preproc.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import argparse
  2. def parse_file(file_path):
  3. data = {'heapsize': None, 'is_optimized': None, 'P0': {}, 'P1': {}, 'P2': {}}
  4. current_party = None
  5. with open(file_path, 'r') as file:
  6. lines = file.readlines()
  7. for line in lines:
  8. if line.startswith("heapsize:"):
  9. data['heapsize'] = int(line.split(":")[1].strip())
  10. elif line.startswith("is_optimized:"):
  11. data['is_optimized'] = int(line.split(":")[1].strip())
  12. elif line.startswith("===== P"):
  13. current_party = line.split()[1]
  14. elif current_party and "milliseconds wall clock time" in line:
  15. time_parts = line.split()
  16. data[current_party]['wall_clock_time'] = int(time_parts[0])
  17. elif current_party and "messages sent" in line:
  18. data[current_party]['messages_sent'] = int(line.split()[0])
  19. elif current_party and "message bytes sent" in line:
  20. data[current_party]['message_bytes_sent'] = int(line.split()[0])
  21. return data
  22. def main():
  23. parser = argparse.ArgumentParser(description="Parse file and extract heapsize, is_optimized, wall clock time, messages sent, and message bytes sent for all three parties.")
  24. parser.add_argument("file_path", type=str, help="Path to the input file")
  25. args = parser.parse_args()
  26. file_path = args.file_path
  27. parsed_data = parse_file(file_path)
  28. print(f"{parsed_data['heapsize']}")
  29. print(f"{parsed_data['is_optimized']}")
  30. #for party, party_data in parsed_data.items():
  31. # if party != 'heapsize' and party != 'is_optimized':
  32. # print(f"Party: {party}")
  33. # if 'wall_clock_time' in party_data:
  34. # print(f"Wall Clock Time: {party_data['wall_clock_time']} ms")
  35. # if 'messages_sent' in party_data:
  36. # print(f"Messages Sent: {party_data['messages_sent']}")
  37. # if 'message_bytes_sent' in party_data:
  38. # print(f"Message Bytes Sent: {party_data['message_bytes_sent']}")
  39. # print()
  40. # max_wall_clock_time = 0
  41. # max_message_bytes_sent = 0
  42. max_wall_clock_time = 0
  43. max_message_bytes_sent = 0
  44. for party, party_data in parsed_data.items():
  45. if party != 'heapsize' and party != 'is_optimized':
  46. #print(f"Party: {party}")
  47. if 'wall_clock_time' in party_data:
  48. wall_clock_time = party_data['wall_clock_time']
  49. # print(f"Wall Clock Time: {wall_clock_time} ms")
  50. max_wall_clock_time = max(max_wall_clock_time, wall_clock_time)
  51. if 'messages_sent' in party_data:
  52. messages_sent = party_data['messages_sent']
  53. #print(f"Messages Sent: {messages_sent}")
  54. if 'message_bytes_sent' in party_data:
  55. message_bytes_sent = party_data['message_bytes_sent']
  56. #print(f"Message Bytes Sent: {message_bytes_sent}")
  57. max_message_bytes_sent = max(max_message_bytes_sent, message_bytes_sent)
  58. #print()
  59. print(f"{max_wall_clock_time}")
  60. print(f"{max_message_bytes_sent}")
  61. if __name__ == "__main__":
  62. main()