diff options
author | Micah Anderson <micah@riseup.net> | 2014-11-11 11:53:55 -0500 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2014-11-11 11:53:55 -0500 |
commit | 7d5c3dcd969161322deed6c43f8a6a3cb92c3369 (patch) | |
tree | 109b05c88c7252d7609ef324d62ef9dd7f06123f /examples/bench/plot_latency.py | |
parent | 44be832c5708baadd146cb954befbc3dcad8d463 (diff) |
upgrade to 14.4.1upstream/14.4.1
Diffstat (limited to 'examples/bench/plot_latency.py')
-rw-r--r-- | examples/bench/plot_latency.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/examples/bench/plot_latency.py b/examples/bench/plot_latency.py new file mode 100644 index 0000000..f50ef29 --- /dev/null +++ b/examples/bench/plot_latency.py @@ -0,0 +1,84 @@ +"""Plot latency data from messaging benchmarks. + +To generate the data for each library, I started the server and then did +the following for each client:: + + from xmlrpc_client import client + for i in range(9): + s = '0'*10**i + print s + %timeit client.echo(s) +""" + +from matplotlib.pylab import * + +rawdata = """# Data in milliseconds +Bytes JSONRPC PYRO XMLRPC pyzmq_copy pyzmq_nocopy +1 2.15 0.186 2.07 0.111 0.136 +10 2.49 0.187 1.87 0.115 0.137 +100 2.5 0.189 1.9 0.126 0.138 +1000 2.54 0.196 1.91 0.129 0.141 +10000 2.91 0.271 2.77 0.204 0.197 +100000 6.65 1.44 9.17 0.961 0.546 +1000000 50.2 15.8 81.5 8.39 2.25 +10000000 491 159 816 91.7 25.2 +100000000 5010 1560 8300 893 248 + +""" +with open('latency.csv','w') as f: + f.writelines(rawdata) + +data = csv2rec('latency.csv',delimiter='\t') + +loglog(data.bytes, data.xmlrpc*1000, label='XMLRPC') +loglog(data.bytes, data.jsonrpc*1000, label='JSONRPC') +loglog(data.bytes, data.pyro*1000, label='Pyro') +loglog(data.bytes, data.pyzmq_nocopy*1000, label='PyZMQ') +loglog(data.bytes, len(data.bytes)*[60], label='Ping') +legend(loc=2) +title('Latency') +xlabel('Number of bytes') +ylabel('Round trip latency ($\mu s$)') +grid(True) +show() +savefig('latency.png') + +clf() + +semilogx(data.bytes, 1000/data.xmlrpc, label='XMLRPC') +semilogx(data.bytes, 1000/data.jsonrpc, label='JSONRPC') +semilogx(data.bytes, 1000/data.pyro, label='Pyro') +semilogx(data.bytes, 1000/data.pyzmq_nocopy, label='PyZMQ') +legend(loc=1) +xlabel('Number of bytes') +ylabel('Message/s') +title('Message Throughput') +grid(True) +show() +savefig('msgs_sec.png') + +clf() + +loglog(data.bytes, 1000/data.xmlrpc, label='XMLRPC') +loglog(data.bytes, 1000/data.jsonrpc, label='JSONRPC') +loglog(data.bytes, 1000/data.pyro, label='Pyro') +loglog(data.bytes, 1000/data.pyzmq_nocopy, label='PyZMQ') +legend(loc=3) +xlabel('Number of bytes') +ylabel('Message/s') +title('Message Throughput') +grid(True) +show() +savefig('msgs_sec_log.png') + +clf() + +semilogx(data.bytes, data.pyro/data.pyzmq_nocopy, label="No-copy") +semilogx(data.bytes, data.pyro/data.pyzmq_copy, label="Copy") +xlabel('Number of bytes') +ylabel('Ratio throughputs') +title('PyZMQ Throughput/Pyro Throughput') +grid(True) +legend(loc=2) +show() +savefig('msgs_sec_ratio.png') |