Skip to content

Instantly share code, notes, and snippets.

@keewon
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keewon/96ae41903217a703ab0e to your computer and use it in GitHub Desktop.
Save keewon/96ae41903217a703ab0e to your computer and use it in GitHub Desktop.
Graph with Python
import matplotlib.pyplot as plt
# load data
qos0 = open('qos0.txt').readlines()
qos1 = open('qos1.txt').readlines()
qos2 = open('qos2.txt').readlines()
qos0 = qos0[1:]
qos1 = qos1[1:]
qos2 = qos2[1:]
x0 = []
y0 = []
x1 = []
y1 = []
x2 = []
y2 = []
# time,connected,subscribed,published_per_sec,published,puback,received,response
for l in qos0:
items = l.split(',')
x0.append(items[3])
y0.append(items[7])
for l in qos1:
items = l.split(',')
x1.append(items[3])
y1.append(items[7])
for l in qos2:
items = l.split(',')
x2.append(items[3])
y2.append(items[7])
# plot
plt.title('MQTT performance on my Macbook Air')
plt.xlabel('publishes per seconds')
plt.ylabel('response time')
plt.plot(x0, y0, 'r', label='qos0')
plt.hold(True)
plt.plot(x1, y1, 'g', label='qos1')
plt.hold(True)
plt.plot(x2, y2, 'b', label='qos2')
plt.legend(loc='upper left')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment