USB_VCP performance
Posted: Wed May 20, 2015 6:48 pm
I have measured USB performance (latency, read rate) on various MCU's (teensy, DUE, maple, UNO) using the framework described at
http://www.pjrc.com/teensy/benchmark_us ... ceive.html
Using the same host harness (on Ubuntu laptop), I used the following pyboard program to measure latency
The results for the pyboard were a bit slow compared to teensy 3.1 and even UNO, and the test failed if the host tried sending more than 500 bytes. The 10ms delay is probably dictated by timer3 USBD_CDC_POLLING_INTERVAL
The readbytes test did NOT really work on the pyboard. the host sends 30000 bytes for a total of 1 million bytes. In fact, the host seems to send at its maximum rate as there appears to be no feedback (flow control) from the pyboard USB. With no "recv" in the pyboard program, the host side is happy to send away! Here is the little pyboard receiver
As usual, I could have messed up the Python (not my "native" language), but if not, I'm surprised that the pyboard USB_VCP is not doing some sort of USB flow control??
readbytes on teensy 3.1 averages 1,150,244 bytes/second, on UNO average is 11,761 bytes/sec.
EDIT: if I change the host send size from 30000 to 512, then the pyboard does do some recv's -- though not 1 million bytes worth.
http://www.pjrc.com/teensy/benchmark_us ... ceive.html
Using the same host harness (on Ubuntu laptop), I used the following pyboard program to measure latency
Code: Select all
# from teensy latency_test /dev/ttyACM0
import pyb
usb_vcp = pyb.USB_VCP()
pyb.LED(1).on()
pyb.delay(5000)
# wait for host to connect to ACM0
while not usb_vcp.isconnected():
pass
pyb.LED(1).off()
while True:
if usb_vcp.any() :
x = usb_vcp.read(1)
if x == b'x' :
usb_vcp.write('0')
usb_vcp.write('1')
usb_vcp.write('2')
usb_vcp.write('x')
Code: Select all
teensy 3.1 UNO pyboard
latency @ 1 bytes: 0.10 ms 4.09 ms 10.00 ms
latency @ 2 bytes: 0.10 ms 4.09 ms 10.00 ms
latency @ 12 bytes: 0.10 ms 4.09 ms 10.00 ms
latency @ 30 bytes: 0.14 ms 4.09 ms 10.00 ms
latency @ 62 bytes: 0.19 ms 8.19 ms 10.00 ms
latency @ 71 bytes: 0.21 ms 8.19 ms 10.00 ms
latency @ 128 bytes: 0.26 ms 12.28 ms 10.00 ms
latency @ 500 bytes: 0.64 ms 45.05 ms 20.00 ms
latency @ 1000 bytes: 1.07 ms 86.01 ms ?
latency @ 2000 bytes: 2.03 ms 172.04 ms ?
latency @ 4000 bytes: 3.88 ms 344.07 ms ?
latency @ 8000 bytes: 7.45 ms 684.04 ms ?
Code: Select all
# from teensy latency_test /dev/ttyACM0 TODO ??
# recv is blocking, read is not
import pyb
usb_vcp = pyb.USB_VCP()
pyb.LED(1).on()
pyb.delay(5000)
# wait for host to connect to ACM0
while not usb_vcp.isconnected():
pass
pyb.LED(1).off()
while True:
x = usb_vcp.recv(500)
readbytes on teensy 3.1 averages 1,150,244 bytes/second, on UNO average is 11,761 bytes/sec.
EDIT: if I change the host send size from 30000 to 512, then the pyboard does do some recv's -- though not 1 million bytes worth.