generate_graphs.py
Go to the documentation of this file.
1 #!/usr/bin/python3
2 
3 #
4 # This script assumes that the set of CSV files produced by "generate_csv.sh" is provided as input
5 # and that locally there is the "results" folder.
6 #
7 
8 # results for TCP:
9 INPUT_FILE_PUSHPULL_TCP_THROUGHPUT="results/pushpull_tcp_thr_results.csv"
10 INPUT_FILE_REQREP_TCP_LATENCY="results/reqrep_tcp_lat_results.csv"
11 TCP_LINK_GPBS=100
12 
13 # results for INPROC:
14 INPUT_FILE_PUSHPULL_INPROC_THROUGHPUT="results/pushpull_inproc_thr_results.csv"
15 INPUT_FILE_PUBSUBPROXY_INPROC_THROUGHPUT="results/pubsubproxy_inproc_thr_results.csv"
16 
17 
18 # dependencies
19 #
20 # pip3 install matplotlib
21 #
22 
23 import matplotlib.pyplot as plt
24 import numpy as np
25 
26 
27 # functions
28 
29 def plot_throughput(csv_filename, title, is_tcp=False):
30  message_size_bytes, message_count, pps, mbps = np.loadtxt(csv_filename, delimiter=',', unpack=True)
31 
32  fig, ax1 = plt.subplots()
33 
34  # PPS axis
35  color = 'tab:red'
36  ax1.set_xlabel('Message size [B]')
37  ax1.set_ylabel('PPS [Mmsg/s]', color=color)
38  ax1.semilogx(message_size_bytes, pps / 1e6, label='PPS [Mmsg/s]', marker='x', color=color)
39  ax1.tick_params(axis='y', labelcolor=color)
40 
41  # GBPS axis
42  color = 'tab:blue'
43  ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
44  ax2.set_ylabel('Throughput [Gb/s]', color=color)
45  ax2.semilogx(message_size_bytes, mbps / 1e3, label='Throughput [Gb/s]', marker='o')
46  if is_tcp:
47  ax2.set_yticks(np.arange(0, TCP_LINK_GPBS + 1, TCP_LINK_GPBS/10))
48  ax2.tick_params(axis='y', labelcolor=color)
49  ax2.grid(True)
50 
51  plt.title(title)
52  fig.tight_layout() # otherwise the right y-label is slightly clippe
53  plt.savefig(csv_filename.replace('.csv', '.png'))
54  plt.show()
55 
56 def plot_latency(csv_filename, title):
57  message_size_bytes, message_count, lat = np.loadtxt(csv_filename, delimiter=',', unpack=True)
58  plt.semilogx(message_size_bytes, lat, label='Latency [us]', marker='o')
59 
60  plt.xlabel('Message size [B]')
61  plt.ylabel('Latency [us]')
62  plt.grid(True)
63  plt.title(title)
64  plt.savefig(csv_filename.replace('.csv', '.png'))
65  plt.show()
66 
67 
68 # main
69 
70 plot_throughput(INPUT_FILE_PUSHPULL_TCP_THROUGHPUT, 'ZeroMQ PUSH/PULL socket throughput, TCP transport', is_tcp=True)
71 plot_throughput(INPUT_FILE_PUSHPULL_INPROC_THROUGHPUT, 'ZeroMQ PUSH/PULL socket throughput, INPROC transport')
72 plot_throughput(INPUT_FILE_PUBSUBPROXY_INPROC_THROUGHPUT, 'ZeroMQ PUB/SUB PROXY socket throughput, INPROC transport')
73 plot_latency(INPUT_FILE_REQREP_TCP_LATENCY, 'ZeroMQ REQ/REP socket latency, TCP transport')
generate_graphs.plot_throughput
def plot_throughput(csv_filename, title, is_tcp=False)
Definition: generate_graphs.py:29
generate_graphs.plot_latency
def plot_latency(csv_filename, title)
Definition: generate_graphs.py:56


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:51