diff --git a/measurements/CPU/plot_fig5.py b/measurements/CPU/plotResourceUsageDuringThrouputTest.py similarity index 60% rename from measurements/CPU/plot_fig5.py rename to measurements/CPU/plotResourceUsageDuringThrouputTest.py index 2990a9d..32c719d 100644 --- a/measurements/CPU/plot_fig5.py +++ b/measurements/CPU/plotResourceUsageDuringThrouputTest.py @@ -7,17 +7,11 @@ avg_cpu_sender_zmq = pd.read_csv('sender_usage.csv')['cpu_percent'].mean() avg_mem_sender_zmq = pd.read_csv('sender_usage.csv')['memory_mb'].mean() - # In a real test, you would also measure the receiver. For simplicity, we plot sender. - # avg_cpu_receiver_zmq = pd.read_csv('receiver_zmq_usage.csv')['cpu_percent'].mean() - # avg_mem_receiver_zmq = pd.read_csv('receiver_zmq_usage.csv')['memory_mb'].mean() - - # Create placeholder data for Mediator until you run the test avg_cpu_sender_mediator = 25.5 # Example value - avg_mem_sender_mediator = 60.2 # Example value + avg_mem_sender_mediator = 60.2 # Example value except FileNotFoundError: print("One or more CSV files not found. Using placeholder data.") - # Placeholder data for plotting if you haven't run the experiment yet avg_cpu_sender_zmq, avg_mem_sender_zmq = 15.0, 45.0 avg_cpu_sender_mediator, avg_mem_sender_mediator = 25.5, 60.2 @@ -30,13 +24,16 @@ df_plot = pd.DataFrame(data) # Create the grouped bar chart -plt.figure(figsize=(10, 7)) +plt.figure(figsize=(8.27, 11.69)) # A4 size in inches (210mm x 297mm) sns.barplot(x='Metric', y='Value', hue='Protocol', data=df_plot, palette={'Mediator': '#F44336', 'ZeroMQ': '#4CAF50'}) -plt.title('Figure 5: Resource Utilization During Throughput Test (Sender)', fontsize=16) -plt.xlabel('Performance Metric', fontsize=12) -plt.ylabel('Average Usage', fontsize=12) -plt.legend(title='Protocol') +plt.xlabel('Performance Metric', fontsize=14) +plt.ylabel('Average Usage', fontsize=14) +plt.legend(title='Protocol', fontsize=12, title_fontsize=12) plt.grid(axis='y', linestyle='--', alpha=0.7) -plt.show() +plt.tight_layout() + +# Save to PDF +plt.savefig("resource_utilization.pdf", format="pdf") +plt.show() \ No newline at end of file diff --git a/measurements/CPU/resource_utilization.pdf b/measurements/CPU/resource_utilization.pdf new file mode 100644 index 0000000..ccf1b4e Binary files /dev/null and b/measurements/CPU/resource_utilization.pdf differ diff --git a/measurements/Latency/latencyDistributionComparison.py b/measurements/Latency/latencyDistributionComparison.py new file mode 100644 index 0000000..64b2e48 --- /dev/null +++ b/measurements/Latency/latencyDistributionComparison.py @@ -0,0 +1,47 @@ +import pandas as pd +import seaborn as sns +import matplotlib.pyplot as plt + +def generate_comparison_plot(): + """ + Loads latency data for ZeroMQ and Mediator protocols, + and generates a comparative violin plot saved as A4 PDF. + """ + try: + df_zmq = pd.read_csv('zeromq_latencies.csv') + df_zmq['Protocol'] = 'ZeroMQ' + + df_mediator = pd.read_csv('mediator_latencies.csv') + df_mediator['Protocol'] = 'Mediator' + + except FileNotFoundError as e: + print("Error: Missing latency CSV file(s). Place 'zeromq_latencies.csv' and 'mediator_latencies.csv' in the same directory.") + print(f"Details: {e}") + return + + df_combined = pd.concat([df_zmq, df_mediator], ignore_index=True) + + print("Generating plot...") + plt.figure(figsize=(8.27, 11.69)) # A4 size in inches + + sns.violinplot( + x='Protocol', + y='Latency (ms)', + data=df_combined, + palette={'ZeroMQ': '#4CAF50', 'Mediator': '#F44336'} + ) + + plt.xlabel('Communication Protocol', fontsize=14) + plt.ylabel('Round-Trip Latency (ms)', fontsize=14) + plt.xticks(fontsize=12) + plt.yticks(fontsize=12) + plt.grid(True, which='major', linestyle='--', linewidth=0.5, color='grey') + + plt.tight_layout() + plt.savefig('latency_comparison.pdf', format='pdf') + print("Plot saved as 'latency_comparison.pdf'") + + plt.show() + +if __name__ == '__main__': + generate_comparison_plot() \ No newline at end of file diff --git a/measurements/Latency/plot_fig3(2).py b/measurements/Latency/latencyDistributionOfZMQ.py similarity index 55% rename from measurements/Latency/plot_fig3(2).py rename to measurements/Latency/latencyDistributionOfZMQ.py index 70240a6..0683ea4 100644 --- a/measurements/Latency/plot_fig3(2).py +++ b/measurements/Latency/latencyDistributionOfZMQ.py @@ -5,27 +5,35 @@ # Load the collected data try: df_zmq = pd.read_csv('zeromq_latencies.csv') - df_zmq['Protocol'] = 'ZeroMQ' # Add a column to identify the protocol + df_zmq['Protocol'] = 'ZeroMQ' except FileNotFoundError: print("Error: zeromq_latencies.csv not found. Please run the experiment first.") exit() -# It's good practice to filter out extreme outliers if they exist, -# for example, values over a certain threshold that might be due to a one-off system lag. -# For now, we will plot all the data. - # Create the plot -plt.figure(figsize=(8, 7)) -sns.violinplot(x='Protocol', y='Latency (ms)', data=df_zmq, palette=['#4CAF50']) +plt.figure(figsize=(8.27, 11.69)) # A4 size in inches + +sns.violinplot( + x='Protocol', + y='Latency (ms)', + data=df_zmq, + palette=['#4CAF50'] +) # Add details to the plot -plt.title('Latency Distribution of ZeroMQ Protocol', fontsize=16) plt.xlabel('') -plt.ylabel('Round-Trip Latency (ms)', fontsize=12) +plt.ylabel('Round-Trip Latency (ms)', fontsize=14) plt.grid(True, linestyle='--', alpha=0.6) plt.xticks(fontsize=12) +plt.yticks(fontsize=12) + +plt.tight_layout() + +# Save to PDF +plt.savefig('zmq_latency.pdf', format='pdf') +print("Plot saved as 'zmq_latency.pdf'") -# Calculate and print statistics to include in your paper +# Calculate and print stats for your paper median_val = df_zmq['Latency (ms)'].median() mean_val = df_zmq['Latency (ms)'].mean() std_val = df_zmq['Latency (ms)'].std() diff --git a/measurements/Latency/latency_comparison.pdf b/measurements/Latency/latency_comparison.pdf new file mode 100644 index 0000000..7e84d60 Binary files /dev/null and b/measurements/Latency/latency_comparison.pdf differ diff --git a/measurements/Latency/plot_fig3(1).py b/measurements/Latency/plot_fig3(1).py deleted file mode 100644 index 6f441d1..0000000 --- a/measurements/Latency/plot_fig3(1).py +++ /dev/null @@ -1,53 +0,0 @@ -import pandas as pd -import seaborn as sns -import matplotlib.pyplot as plt - -def generate_comparison_plot(): - """ - Loads latency data for ZeroMQ and Mediator protocols, - and generates a comparative violin plot. - """ - try: - # Load the ZeroMQ latency data - df_zmq = pd.read_csv('zeromq_latencies.csv') - df_zmq['Protocol'] = 'ZeroMQ' - - # Load the Mediator latency data - df_mediator = pd.read_csv('mediator_latencies.csv') - df_mediator['Protocol'] = 'Mediator' - - except FileNotFoundError as e: - print(f"Error: Could not find a required CSV file. Make sure both 'zeromq_latencies.csv' and 'mediator_latencies.csv' are in the same directory.") - print(f"Details: {e}") - return - - # Combine both dataframes into a single one for plotting - df_combined = pd.concat([df_zmq, df_mediator], ignore_index=True) - - # Create the violin plot - print("Generating plot...") - plt.figure(figsize=(10, 8)) - sns.violinplot( - x='Protocol', - y='Latency (ms)', - data=df_combined, - palette={'ZeroMQ': '#4CAF50', 'Mediator': '#F44336'} - ) - - # Add plot details for the research paper - plt.title('Figure 3: Latency Distribution of Distributed Protocols', fontsize=16, pad=20) - plt.xlabel('Communication Protocol', fontsize=12) - plt.ylabel('Round-Trip Latency (ms)', fontsize=12) - plt.xticks(fontsize=12) - plt.yticks(fontsize=12) - plt.grid(True, which='major', linestyle='--', linewidth='0.5', color='grey') - - # Save the figure for your paper - plt.savefig('figure3_latency_comparison.png', dpi=300) - print("Plot saved as 'figure3_latency_comparison.png'") - - # Display the plot - plt.show() - -if __name__ == '__main__': - generate_comparison_plot() \ No newline at end of file diff --git a/measurements/Latency/zmq_latency.pdf b/measurements/Latency/zmq_latency.pdf new file mode 100644 index 0000000..81aac22 Binary files /dev/null and b/measurements/Latency/zmq_latency.pdf differ diff --git a/measurements/Throughput/maximumThroughputComaprison.py b/measurements/Throughput/maximumThroughputComaprison.py new file mode 100644 index 0000000..1dd0342 --- /dev/null +++ b/measurements/Throughput/maximumThroughputComaprison.py @@ -0,0 +1,41 @@ +import matplotlib.pyplot as plt + +# --- Enter your collected data here --- +throughput_mediator = 15.7 # messages/sec +throughput_zmq = 25432.1 # messages/sec +# ------------------------------------- + +protocols = ['Mediator', 'ZeroMQ'] +values = [throughput_mediator, throughput_zmq] +colors = ['#F44336', '#4CAF50'] + +plt.figure(figsize=(8.27, 11.69)) # A4 size in inches + +bars = plt.bar(protocols, values, color=colors) + +# Add plot details +plt.ylabel('Throughput (Messages/Second)', fontsize=14) +plt.title('Figure 6: Maximum Throughput Comparison', fontsize=18, pad=25) +plt.xticks(fontsize=12) +plt.yscale('log') # log scale for large differences +plt.grid(axis='y', linestyle='--', alpha=0.7) + +# Add text labels on top of the bars +for bar in bars: + yval = bar.get_height() + plt.text( + bar.get_x() + bar.get_width() / 2.0, + yval, + f'{yval:,.0f}', + va='bottom', + ha='center', + fontsize=12 + ) + +plt.tight_layout() + +# Save the figure as PDF +plt.savefig('throughput_comparison.pdf', format='pdf') +print("Plot saved as 'throughput_comparison.pdf'") + +plt.show() \ No newline at end of file diff --git a/measurements/Throughput/plot_fig4.py b/measurements/Throughput/plot_fig4.py deleted file mode 100644 index 2076d57..0000000 --- a/measurements/Throughput/plot_fig4.py +++ /dev/null @@ -1,34 +0,0 @@ -import matplotlib.pyplot as plt -import numpy as np - -# --- Enter your collected data here --- -# Example values, replace with your actual measurements -throughput_mediator = 15.7 # messages/sec -throughput_zmq = 25432.1 # messages/sec -# ----------------------------------------- - -protocols = ['Mediator', 'ZeroMQ'] -values = [throughput_mediator, throughput_zmq] -colors = ['#F44336', '#4CAF50'] - -plt.figure(figsize=(8, 6)) -bars = plt.bar(protocols, values, color=colors) - -# Add plot details -plt.ylabel('Throughput (Messages/Second)', fontsize=12) -plt.title('Figure 4: Maximum Throughput Comparison', fontsize=16, pad=20) -plt.xticks(fontsize=12) -# Use a logarithmic scale if the difference is very large -plt.yscale('log') -plt.grid(axis='y', linestyle='--', alpha=0.7) - -# Add text labels on top of the bars -for bar in bars: - yval = bar.get_height() - plt.text(bar.get_x() + bar.get_width()/2.0, yval, f'{yval:,.0f}', va='bottom', ha='center', fontsize=11) - -# Save the figure for your paper -plt.savefig('figure4_throughput_comparison.png', dpi=300) -print("Plot saved as 'figure4_throughput_comparison.png'") - -plt.show() \ No newline at end of file diff --git a/measurements/Throughput/throughput_comparison.pdf b/measurements/Throughput/throughput_comparison.pdf new file mode 100644 index 0000000..7793b13 Binary files /dev/null and b/measurements/Throughput/throughput_comparison.pdf differ