1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import matplotlib.pyplot as plt
- import numpy as np
- # Data
- buffer_sizes = [
- 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384,
- 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304
- ]
- python_v1 = [
- 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,
- 249.22, 330.16, 592.22, 337.91, 351.03, 430.14, 462.83, 504.34, 422.68, 946.10
- ]
- python_v2 = [
- 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,
- 89.06, 155.24, 187.37, 171.45, 178.33, 189.40, 247.63, 233.06, 166.80, 249.56
- ]
- c_bandwidth = [
- 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,
- 157.00, 395.94, 471.69, 379.29, 451.65, 514.64, 502.23, 553.53, 370.21, 372.61
- ]
- # Plotting
- plt.figure(figsize=(12, 8))
- plt.plot(buffer_sizes, python_v1, marker='o', label='Python v1 (Mb/s)')
- plt.plot(buffer_sizes, python_v2, marker='o', label='Python v2 (Mb/s)')
- plt.plot(buffer_sizes, c_bandwidth, marker='o', label='C (Mb/s)')
- # Adding titles and labels
- plt.title('Bandwidth Comparison by Buffer Size', fontsize=16)
- plt.xlabel('Buffer Size (bytes)', fontsize=14)
- plt.ylabel('Bandwidth (Mb/s)', fontsize=14)
- # Log scale for x-axis (optional, since buffer sizes grow exponentially)
- plt.xscale('log', base=2)
- # Adding grid, legend, and showing plot
- plt.grid(True, which="both", linestyle="--", linewidth=0.5)
- plt.legend(fontsize=12)
- plt.tight_layout()
- plt.savefig("Plot.pdf")
|