Skip to content

Commit aa16139

Browse files
authored
Merge pull request #166 from saksham-gera/dev
replaced the png format with pdf, now all plots will be saved as pdf
2 parents ec4ed34 + 4988348 commit aa16139

10 files changed

+116
-110
lines changed

measurements/CPU/plot_fig5.py renamed to measurements/CPU/plotResourceUsageDuringThrouputTest.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,11 @@
77
avg_cpu_sender_zmq = pd.read_csv('sender_usage.csv')['cpu_percent'].mean()
88
avg_mem_sender_zmq = pd.read_csv('sender_usage.csv')['memory_mb'].mean()
99

10-
# In a real test, you would also measure the receiver. For simplicity, we plot sender.
11-
# avg_cpu_receiver_zmq = pd.read_csv('receiver_zmq_usage.csv')['cpu_percent'].mean()
12-
# avg_mem_receiver_zmq = pd.read_csv('receiver_zmq_usage.csv')['memory_mb'].mean()
13-
14-
# Create placeholder data for Mediator until you run the test
1510
avg_cpu_sender_mediator = 25.5 # Example value
16-
avg_mem_sender_mediator = 60.2 # Example value
11+
avg_mem_sender_mediator = 60.2 # Example value
1712

1813
except FileNotFoundError:
1914
print("One or more CSV files not found. Using placeholder data.")
20-
# Placeholder data for plotting if you haven't run the experiment yet
2115
avg_cpu_sender_zmq, avg_mem_sender_zmq = 15.0, 45.0
2216
avg_cpu_sender_mediator, avg_mem_sender_mediator = 25.5, 60.2
2317

@@ -30,13 +24,16 @@
3024
df_plot = pd.DataFrame(data)
3125

3226
# Create the grouped bar chart
33-
plt.figure(figsize=(10, 7))
27+
plt.figure(figsize=(8.27, 11.69)) # A4 size in inches (210mm x 297mm)
3428
sns.barplot(x='Metric', y='Value', hue='Protocol', data=df_plot, palette={'Mediator': '#F44336', 'ZeroMQ': '#4CAF50'})
3529

36-
plt.title('Figure 5: Resource Utilization During Throughput Test (Sender)', fontsize=16)
37-
plt.xlabel('Performance Metric', fontsize=12)
38-
plt.ylabel('Average Usage', fontsize=12)
39-
plt.legend(title='Protocol')
30+
plt.xlabel('Performance Metric', fontsize=14)
31+
plt.ylabel('Average Usage', fontsize=14)
32+
plt.legend(title='Protocol', fontsize=12, title_fontsize=12)
4033
plt.grid(axis='y', linestyle='--', alpha=0.7)
4134

42-
plt.show()
35+
plt.tight_layout()
36+
37+
# Save to PDF
38+
plt.savefig("resource_utilization.pdf", format="pdf")
39+
plt.show()
14.3 KB
Binary file not shown.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pandas as pd
2+
import seaborn as sns
3+
import matplotlib.pyplot as plt
4+
5+
def generate_comparison_plot():
6+
"""
7+
Loads latency data for ZeroMQ and Mediator protocols,
8+
and generates a comparative violin plot saved as A4 PDF.
9+
"""
10+
try:
11+
df_zmq = pd.read_csv('zeromq_latencies.csv')
12+
df_zmq['Protocol'] = 'ZeroMQ'
13+
14+
df_mediator = pd.read_csv('mediator_latencies.csv')
15+
df_mediator['Protocol'] = 'Mediator'
16+
17+
except FileNotFoundError as e:
18+
print("Error: Missing latency CSV file(s). Place 'zeromq_latencies.csv' and 'mediator_latencies.csv' in the same directory.")
19+
print(f"Details: {e}")
20+
return
21+
22+
df_combined = pd.concat([df_zmq, df_mediator], ignore_index=True)
23+
24+
print("Generating plot...")
25+
plt.figure(figsize=(8.27, 11.69)) # A4 size in inches
26+
27+
sns.violinplot(
28+
x='Protocol',
29+
y='Latency (ms)',
30+
data=df_combined,
31+
palette={'ZeroMQ': '#4CAF50', 'Mediator': '#F44336'}
32+
)
33+
34+
plt.xlabel('Communication Protocol', fontsize=14)
35+
plt.ylabel('Round-Trip Latency (ms)', fontsize=14)
36+
plt.xticks(fontsize=12)
37+
plt.yticks(fontsize=12)
38+
plt.grid(True, which='major', linestyle='--', linewidth=0.5, color='grey')
39+
40+
plt.tight_layout()
41+
plt.savefig('latency_comparison.pdf', format='pdf')
42+
print("Plot saved as 'latency_comparison.pdf'")
43+
44+
plt.show()
45+
46+
if __name__ == '__main__':
47+
generate_comparison_plot()

measurements/Latency/plot_fig3(2).py renamed to measurements/Latency/latencyDistributionOfZMQ.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,35 @@
55
# Load the collected data
66
try:
77
df_zmq = pd.read_csv('zeromq_latencies.csv')
8-
df_zmq['Protocol'] = 'ZeroMQ' # Add a column to identify the protocol
8+
df_zmq['Protocol'] = 'ZeroMQ'
99
except FileNotFoundError:
1010
print("Error: zeromq_latencies.csv not found. Please run the experiment first.")
1111
exit()
1212

13-
# It's good practice to filter out extreme outliers if they exist,
14-
# for example, values over a certain threshold that might be due to a one-off system lag.
15-
# For now, we will plot all the data.
16-
1713
# Create the plot
18-
plt.figure(figsize=(8, 7))
19-
sns.violinplot(x='Protocol', y='Latency (ms)', data=df_zmq, palette=['#4CAF50'])
14+
plt.figure(figsize=(8.27, 11.69)) # A4 size in inches
15+
16+
sns.violinplot(
17+
x='Protocol',
18+
y='Latency (ms)',
19+
data=df_zmq,
20+
palette=['#4CAF50']
21+
)
2022

2123
# Add details to the plot
22-
plt.title('Latency Distribution of ZeroMQ Protocol', fontsize=16)
2324
plt.xlabel('')
24-
plt.ylabel('Round-Trip Latency (ms)', fontsize=12)
25+
plt.ylabel('Round-Trip Latency (ms)', fontsize=14)
2526
plt.grid(True, linestyle='--', alpha=0.6)
2627
plt.xticks(fontsize=12)
28+
plt.yticks(fontsize=12)
29+
30+
plt.tight_layout()
31+
32+
# Save to PDF
33+
plt.savefig('zmq_latency.pdf', format='pdf')
34+
print("Plot saved as 'zmq_latency.pdf'")
2735

28-
# Calculate and print statistics to include in your paper
36+
# Calculate and print stats for your paper
2937
median_val = df_zmq['Latency (ms)'].median()
3038
mean_val = df_zmq['Latency (ms)'].mean()
3139
std_val = df_zmq['Latency (ms)'].std()
16.2 KB
Binary file not shown.

measurements/Latency/plot_fig3(1).py

Lines changed: 0 additions & 53 deletions
This file was deleted.
13.8 KB
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import matplotlib.pyplot as plt
2+
3+
# --- Enter your collected data here ---
4+
throughput_mediator = 15.7 # messages/sec
5+
throughput_zmq = 25432.1 # messages/sec
6+
# -------------------------------------
7+
8+
protocols = ['Mediator', 'ZeroMQ']
9+
values = [throughput_mediator, throughput_zmq]
10+
colors = ['#F44336', '#4CAF50']
11+
12+
plt.figure(figsize=(8.27, 11.69)) # A4 size in inches
13+
14+
bars = plt.bar(protocols, values, color=colors)
15+
16+
# Add plot details
17+
plt.ylabel('Throughput (Messages/Second)', fontsize=14)
18+
plt.title('Figure 6: Maximum Throughput Comparison', fontsize=18, pad=25)
19+
plt.xticks(fontsize=12)
20+
plt.yscale('log') # log scale for large differences
21+
plt.grid(axis='y', linestyle='--', alpha=0.7)
22+
23+
# Add text labels on top of the bars
24+
for bar in bars:
25+
yval = bar.get_height()
26+
plt.text(
27+
bar.get_x() + bar.get_width() / 2.0,
28+
yval,
29+
f'{yval:,.0f}',
30+
va='bottom',
31+
ha='center',
32+
fontsize=12
33+
)
34+
35+
plt.tight_layout()
36+
37+
# Save the figure as PDF
38+
plt.savefig('throughput_comparison.pdf', format='pdf')
39+
print("Plot saved as 'throughput_comparison.pdf'")
40+
41+
plt.show()

measurements/Throughput/plot_fig4.py

Lines changed: 0 additions & 34 deletions
This file was deleted.
14.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)