Networking Libraries Benchmark
You may have noticed that recently we have been busy working on a new official networking library:
Unlike the previous library, the new library does not require polling and provides the standard Berkeley sockets API.
The performance improvement with the old library is huge and we provide you with all the sources to repeat the benchmarks by yourself.
As a simple benchmark we are sending and receiving back, through a TCP Echo Server, 1,000 packets of 127 bytes each and we measure how many bits per second we transmit and receive.
Here are the results:
- Legacy "EthernetNetIf" library:
- New mbed official networking library:
That's an improvement of:
import socket import random, string from time import time ECHO_SERVER_ADDRESS = "192.168.0.50" ECHO_SERVER_PORT = 7 N_PACKETS = 1000 LEN_PACKET = 127 TOT_BITS = (LEN_PACKET * N_PACKETS * 8) * 2. # TX bits + RX bits PACKET = ''.join(random.choice(string.ascii_uppercase+string.digits) for _ in range(LEN_PACKET)) MEGA = 1024 * 1024. UPDATE_STEP = (N_PACKETS/10) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT)) start = time() for i in range(N_PACKETS): if (i % UPDATE_STEP) == 0: print "%.2f%%" % (float(i)/float(N_PACKETS) * 100.) s.sendall(PACKET) data = s.recv(LEN_PACKET) assert len(data) == LEN_PACKET t = time() - start s.close() print "TX+RX Throughput: (%.3f)Mbits/s" % ((TOT_BITS / t) / MEGA)
Echo Sever based on the legacy libraries:
Echo Server based on the legacy EthernetNetIf libraries used for a performance comparison with the new networking libraries
Echo Server based on the new mbed official libraries:
11 comments on Networking Libraries Benchmark:
Please log in to post comments.