trust_promo.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. log_file = open("trust_levels.log", "r").readlines()
  2. trust_promo_file = open("trust_promo"+".csv", "w")
  3. trust_promo_file.write("Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n")
  4. bridges = 0
  5. promo = 0
  6. req_size = 0
  7. req_size_std = 0
  8. req_time = 0
  9. req_time_std = 0
  10. resp_size = 0
  11. resp_size_std = 0
  12. resp_time = 0
  13. resp_time_std = 0
  14. resp_handle_time = 0
  15. resp_handle_std = 0
  16. endline = 0
  17. # Loop over the remaining lines in the file
  18. for line in log_file:
  19. if "***START" in line:
  20. bridges = line.split()[1].split("*")[0]
  21. elif "TRUST-PROMOTION" in line:
  22. promo = 1
  23. elif promo:
  24. value = line.split(" = ")
  25. if value[0].startswith("Average"):
  26. if "request" in value[0]:
  27. if "size" in value[0]:
  28. raw_size = value[1].split(" ")
  29. req_size = raw_size[0]
  30. else:
  31. raw_size = value[1]
  32. req_time = raw_size[:-3]
  33. else:
  34. if "size" in value[0]:
  35. raw_size = value[1].split(" ")
  36. resp_size = raw_size[0]
  37. else:
  38. raw_size = value[1]
  39. if "handling" in value[0]:
  40. resp_handle_time = raw_size[:-3]
  41. elif (value[1][-3]) != "m":
  42. sec = value[1][:-3]
  43. resp_time = float(sec)*1000
  44. else:
  45. resp_time = raw_size[:-3]
  46. elif value[0].startswith("Request"):
  47. if "size" in value[0]:
  48. raw_size = value[1].split(" ")
  49. req_size_std = raw_size[0]
  50. else:
  51. if "µ" in value[1]:
  52. micro_sec = value[1].split("µ")
  53. to_sec = float(micro_sec[0])*0.001
  54. else:
  55. to_sec = value[1][:-3]
  56. req_time_std = to_sec
  57. elif value[0].startswith("Response"):
  58. if "size" in value[0]:
  59. raw_size = value[1].split(" ")
  60. resp_size_std = raw_size[0]
  61. elif "bytes" in value[1]:
  62. continue
  63. else:
  64. if "µ" in value[1]:
  65. micro_sec = value[1].split("µ")
  66. to_sec = float(micro_sec[0])*0.001
  67. else:
  68. to_sec = value[1][:-3]
  69. if "handling" in value[0]:
  70. resp_handle_time_std = to_sec
  71. endline = 1
  72. else:
  73. resp_time_std = to_sec
  74. if endline == 1:
  75. if promo == 1:
  76. trust_promo_file.write(str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n")
  77. promo = 0
  78. endline = 0
  79. trust_promo_file.close()
  80. print("Done.")