test_1_analysis.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import pickle
  2. import pandas as pd
  3. def get_average_active_secs(df, repeat=1):
  4. mask = (df > 0.005) & (df < 0.020)
  5. active = df[mask]
  6. secs = len(active) / 1000
  7. return secs / repeat
  8. def analyze_benchmark(benchmark):
  9. with open(f"output/test_1_{benchmark}_original.pickle", "rb") as f:
  10. d1 = pickle.load(f)
  11. with open(f"output/test_1_{benchmark}_ckpt.pickle", "rb") as f:
  12. d2 = pickle.load(f)
  13. avg_orig = get_average_active_secs(d1, 2)
  14. avg_ckpt = get_average_active_secs(d2, 5)
  15. return avg_orig, avg_ckpt
  16. def do_analysis(benchmarks):
  17. results = []
  18. for benchmark in benchmarks:
  19. try:
  20. avg_orig, avg_ckpt = analyze_benchmark(benchmark)
  21. except:
  22. continue
  23. results.append({
  24. "benchmark": benchmark,
  25. "original (s)": avg_orig,
  26. "ckpt (s)": avg_ckpt,
  27. "overhead (%)": ((avg_ckpt / avg_orig) - 1) * 100,
  28. })
  29. d = pd.DataFrame(results)
  30. print(d)
  31. avg_overhead = d["overhead (%)"].mean()
  32. print(f"average overhead: {avg_overhead:.2f}%")
  33. def main():
  34. benchmarks = ["vFFT", "vConv2d", "vCrc", "vBasicMath", "vSha", "vStringSearch", "vAes", "vMatMul"]
  35. benchmarks = ["vFFT", "vCrc", "vBasicMath", "vSha"]
  36. do_analysis(benchmarks)
  37. if __name__ == "__main__":
  38. main()