make_tables.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import csv
  2. import sys
  3. import pandas as pd
  4. import numpy as np
  5. def main():
  6. perf = open("performance_stats"+".csv", "w", newline='')
  7. # latency = open("latency.csv", "w", newline='')
  8. # load = open("load.csv", "w", newline='')
  9. # bursty = open("burst.csv", "w",newline='')
  10. protocols=["Open Invitation", "Trust Promotion(0->1)",
  11. "Trust Migration (0->1)", "Level Up (1->4)", "Issue Invitation",
  12. "Redeem Invitation", "Check Blockage 5%", "Check Blockage 50%", "Check Blockage 100%", "Blockage Migration"]
  13. files = ["updated_levels.csv", "trust_promo.csv", "trust_mig.csv", "level2.csv",
  14. "issue_invites.csv", "redeem_invites.csv","checkblockage5.csv",
  15. "checkblockage50.csv","checkblockage100.csv","updated_blockage50.csv"]
  16. csv_cols = ["RequestS", "RequestT","Rtstdev","ResponseS","ResponseT",
  17. "ReTstdev", "ResponseHT", "RHTstdev"]
  18. perf_columns = ["Protocol","Request Size", "Request Time", "sigma",
  19. "Response Size","Response Time", "sigma",
  20. "Response Handling Time", "sigma"]
  21. # lat_columns = ["Protocol", "Client Side Latency (ms)", "Users/s Response",
  22. # "ms/Response"]
  23. # load_columns = ["Protocol", "Users/core", "User/day Requests",
  24. # "Users/week Requests", "Users/month Requests"]
  25. worst_resp = 0
  26. perfwriter = csv.writer(perf, delimiter=',')
  27. perfwriter.writerow(perf_columns)
  28. # latwriter = csv.writer(latency, delimiter=',')
  29. # latwriter.writerow(lat_columns)
  30. # loadwriter = csv.writer(load, delimiter=',')
  31. # loadwriter.writerow(load_columns)
  32. for i, protocol in enumerate(protocols):
  33. columns = ["Percent","Bridges", "RequestS", "Rsstdev", "RequestT",
  34. "Rtstdev", "ResponseS","Restdev","ResponseT",
  35. "ReTstdev", "ResponseHT", "RHTstdev"]
  36. df = pd.read_csv(files[i], usecols=columns)
  37. perf_in = []
  38. # lat_in = []
  39. # req = 0.0
  40. perf_in.append(protocol)
  41. # lat_in.append(protocol)
  42. for item in csv_cols:
  43. row = df[item].loc[df['Bridges']==900].values
  44. if "stdev" in item:
  45. rounded = np.round(row[0], decimals=1)
  46. else:
  47. rounded = np.round(row[0], decimals=3)
  48. perf_in.append(rounded)
  49. rounded = np.round(row[0], decimals=1)
  50. if item == "RequestT":
  51. req = np.round(rounded, decimals=1)
  52. # lat_in.append(req)
  53. # elif item == "ResponseHT":
  54. # lat_in[1]=np.round(req+rounded, decimals=1)
  55. elif item == "ResponseT":
  56. resp_sec = np.round(1000/rounded, decimals=1)
  57. resp_core = resp_sec/(1/(60*60*24))
  58. if rounded > worst_resp:
  59. worst_resp = rounded
  60. # lat_in.append(resp_sec)
  61. # lat_in.append(rounded)
  62. perfwriter.writerow(perf_in)
  63. # latwriter.writerow(lat_in)
  64. for i, protocol in enumerate(protocols):
  65. columns = ["Percent","Bridges", "RequestS", "Rsstdev", "RequestT",
  66. "Rtstdev", "ResponseS","Restdev","ResponseT",
  67. "ReTstdev", "ResponseHT", "RHTstdev"]
  68. df = pd.read_csv(files[i], usecols=columns)
  69. # load_in = []
  70. # load_in.append(protocol)
  71. row = df['ResponseT'].loc[df['Bridges']==900].values
  72. rounded = np.round(row[0], decimals=3)
  73. resp_sec = np.round(1000/rounded, decimals=3)
  74. resp_core = int(resp_sec/(1/(60*60*24)))
  75. # load_in.append(resp_core)
  76. if worst_resp > rounded:
  77. secs = int(worst_resp/1000)
  78. # load_in.append(resp_core*secs)
  79. # load_in.append(resp_core*7*secs)
  80. # load_in.append(resp_core*30*secs)
  81. # else:
  82. # load_in.append(resp_core)
  83. # load_in.append(resp_core*7)
  84. # load_in.append(resp_core*30)
  85. # loadwriter.writerow(load_in)
  86. perf.close()
  87. # latency.close()
  88. # load.close()
  89. print("\nDone Tables.\nTable data output to: performance_stats.csv,\n")# latency.csv, load.csv\n")
  90. if __name__ == "__main__":
  91. sys.exit(main())