Update Python Performance Testing authored by jesseg64's avatar jesseg64
[<< Previous Chapter](Using-the-CyDAQ-User-Interface) | [Home](Home) | [Next Chapter >>](System-Testing) 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.
[[_TOC_]] 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:
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. A script was created in [serial_testing.py](https://git.ece.iastate.edu/sd/sdmay23-47/-/blob/master/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
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:
The script can be ran with the following command
A script was created in [serial_testing.py](https://git.ece.iastate.edu/sd/sdmay23-47/-/blob/master/serial_testing.py) that mocks a serial connection with a pseudoterminal, and responds to sampling commands just like the CyDAQ would. ```bash
> Note: This script can only be ran in Unix platforms, as pseudoterminals are not supported on windows python serial_testing.py
```
The script can be ran with the following command Here is an example output of the script
```bash ```
python serial_testing.py ---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)
Here is an example output of the script Command recieved: b'@\x04!'
``` Time: 4.903991460800171
---LISTENER STARTED--- 101350
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'stop!'
Command recieved: b'@\x04!' ```
Time: 4.903991460800171 The above test was ran with 100,000,000 samples saved to a file, and it took under 5 seconds to complete!
101350
Command recieved: b'stop!' 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.
```
The above test was ran with 100,000,000 samples saved to a file, and it took under 5 seconds to complete! ```
---LISTENER STARTED---
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. 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
---LISTENER STARTED--- 136783
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'stop!'
Command recieved: b'@\x04!' ```
Time: 1.806623935699463 The time is now under 2 seconds!
136783
Command recieved: b'stop!' 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.
``` \ No newline at end of file
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.
[<< Previous Chapter](Using-the-CyDAQ-User-Interface) | [Home](Home) | [Next Chapter >>](System-Testing)
\ No newline at end of file