plot.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. # Data
  4. buffer_sizes = [
  5. 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384,
  6. 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304
  7. ]
  8. python_v1 = [
  9. 0.02, 0.03, 0.08, 0.12, 0.48, 0.56, 0.92, 3.16, 4.77, 10.56, 16.82, 52.38, 93.93,
  10. 249.22, 330.16, 592.22, 337.91, 351.03, 430.14, 462.83, 504.34, 422.68, 946.10
  11. ]
  12. python_v2 = [
  13. 0.02, 0.02, 0.03, 0.05, 0.18, 0.44, 0.76, 1.52, 2.80, 6.89, 9.09, 17.71, 47.89,
  14. 89.06, 155.24, 187.37, 171.45, 178.33, 189.40, 247.63, 233.06, 166.80, 249.56
  15. ]
  16. c_bandwidth = [
  17. 0.03, 0.08, 0.09, 0.35, 0.57, 2.11, 2.44, 2.20, 6.50, 13.04, 13.77, 58.35, 83.83,
  18. 157.00, 395.94, 471.69, 379.29, 451.65, 514.64, 502.23, 553.53, 370.21, 372.61
  19. ]
  20. # Plotting
  21. plt.figure(figsize=(12, 8))
  22. plt.plot(buffer_sizes, python_v1, marker='o', label='Python v1 (Mb/s)')
  23. plt.plot(buffer_sizes, python_v2, marker='o', label='Python v2 (Mb/s)')
  24. plt.plot(buffer_sizes, c_bandwidth, marker='o', label='C (Mb/s)')
  25. # Adding titles and labels
  26. plt.title('Bandwidth Comparison by Buffer Size', fontsize=16)
  27. plt.xlabel('Buffer Size (bytes)', fontsize=14)
  28. plt.ylabel('Bandwidth (Mb/s)', fontsize=14)
  29. # Log scale for x-axis (optional, since buffer sizes grow exponentially)
  30. plt.xscale('log', base=2)
  31. # Adding grid, legend, and showing plot
  32. plt.grid(True, which="both", linestyle="--", linewidth=0.5)
  33. plt.legend(fontsize=12)
  34. plt.tight_layout()
  35. plt.savefig("Plot.pdf")