make_tables.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. protocols=["Open Invitation", "Trust Promotion(0->1)",
  8. "Trust Migration (0->1)", "Level Up (1->4)", "Issue Invitation",
  9. "Redeem Invitation", "Check Blockage 5%", "Check Blockage 50%", "Check Blockage 100%", "Blockage Migration"]
  10. files = ["trust_levels.csv", "trust_promo.csv", "trust_mig.csv", "level2.csv",
  11. "invitations.csv", "redeem_invites.csv","check_blockage5.csv",
  12. "check_blockage50.csv","check_blockage100.csv","blockage_migration50.csv"]
  13. csv_cols = ["RequestS", "RequestT","Rtstdev","ResponseS","ResponseT",
  14. "ReTstdev", "ResponseHT", "RHTstdev"]
  15. perf_columns = ["Protocol","Request Size", "Request Time", "sigma",
  16. "Response Size","Response Time", "sigma",
  17. "Response Handling Time", "sigma"]
  18. worst_resp = 0
  19. perfwriter = csv.writer(perf, delimiter=',')
  20. perfwriter.writerow(perf_columns)
  21. for i, protocol in enumerate(protocols):
  22. columns = ["Percent","Bridges", "RequestS", "Rsstdev", "RequestT",
  23. "Rtstdev", "ResponseS","Restdev","ResponseT",
  24. "ReTstdev", "ResponseHT", "RHTstdev"]
  25. df = pd.read_csv(files[i], usecols=columns)
  26. perf_in = []
  27. perf_in.append(protocol)
  28. for item in csv_cols:
  29. row = df[item].loc[df['Bridges']==900].values
  30. if "stdev" in item:
  31. rounded = np.round(row[0], decimals=1)
  32. else:
  33. rounded = np.round(row[0], decimals=3)
  34. perf_in.append(rounded)
  35. rounded = np.round(row[0], decimals=1)
  36. if item == "RequestT":
  37. req = np.round(rounded, decimals=1)
  38. elif item == "ResponseT":
  39. resp_sec = np.round(1000/rounded, decimals=1)
  40. resp_core = resp_sec/(1/(60*60*24))
  41. if rounded > worst_resp:
  42. worst_resp = rounded
  43. perfwriter.writerow(perf_in)
  44. for i, protocol in enumerate(protocols):
  45. columns = ["Percent","Bridges", "RequestS", "Rsstdev", "RequestT",
  46. "Rtstdev", "ResponseS","Restdev","ResponseT",
  47. "ReTstdev", "ResponseHT", "RHTstdev"]
  48. df = pd.read_csv(files[i], usecols=columns)
  49. row = df['ResponseT'].loc[df['Bridges']==900].values
  50. rounded = np.round(row[0], decimals=3)
  51. resp_sec = np.round(1000/rounded, decimals=3)
  52. resp_core = int(resp_sec/(1/(60*60*24)))
  53. if worst_resp > rounded:
  54. secs = int(worst_resp/1000)
  55. perf.close()
  56. print("\nDone Tables.\nTable data output to: performance_stats.csv,\n")
  57. if __name__ == "__main__":
  58. sys.exit(main())