-
Notifications
You must be signed in to change notification settings - Fork 1
Python Performance Testing
<< Previous Chapter | Home | Next Chapter >>
[[TOC]]
The expected maximum transfer speed for the CyDAQ platform is 10 megasamples per second, or 10,000,000 samples per second. Each sample is 2 bytes in size, so that is 20mb per second of transfer.
Because the transfer speed required is so high, it's important to test the baseline platform (in our case, Python), to ensure that such speeds can be achieved. This has been done and verified with the following:
A script was created in serial_testing.py that mocks a serial connection with a pseudoterminal, and responds to sampling commands just like the CyDAQ would.
Note: This script can only be ran in Unix platforms, as pseudoterminals are not supported on windows
The script can be ran with the following command
python serial_testing.pyHere is an example output of the script
---LISTENER STARTED---
Serial<id=0x7fe6c87ff730, open=True>(port='/dev/pts/2', baudrate=921600, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False, dsrdtr=False)
Command recieved: b'@\x04!'
Time: 4.903991460800171
101350
Command recieved: b'stop!'
The above test was ran with 100,000,000 samples saved to a file, and it took under 5 seconds to complete!
The script can be ran again, but with datafile.write(...) commented out, just to see how fast it can process the data without writing. This would resemble live-plotting of data for example, where nothing needs to be saved permanently.
---LISTENER STARTED---
Serial<id=0x7f7ed856f6d0, open=True>(port='/dev/pts/126', baudrate=921600, bytesize=8, parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False, dsrdtr=False)
Command recieved: b'@\x04!'
Time: 1.806623935699463
136783
Command recieved: b'stop!'
The time is now under 2 seconds!
Because both examples were well above 10msps, it's safe to assume that Python itself will not be a bottleneck in getting transfer speeds to the expected value.