So I tested the performance on two computers and following is the data.
In the zip file is the cpp file that ran the test, 2 txt log files for both computers and a excel file analyzing the data and graphing.
What I tested was as you increase the transfer size and you request reads/writes in units of this size, how does performance vary with size. You can see in the image attached that for the faster computer, with the largest transfer size (64BK) speed was 200KB/s.
Transfer size should be a multiple of 64 bytes. For each 64 bytes, 62 bytes is your data and two bytes is used by he driver. So at 1024*64 (64KB) you actually send 62*1024 (63488). Performance is maximized when you send data matching the transfer size.
If you look at my code you'd see three loops. The outer loop increases the transfer size from 1*64 bytes to 1024*64 (64KB). The inner loop replicates each sample 20 times to get a more accurate measure. With the middle loop I meant to test what happens if for a given transfer size (i.e. 640 bytes and 620 bytes of data) I make I read request in multiples of that (i.e. 5*620, 3100). I ended up not doing that and instead only sending the exact multiple of the transfer size because it was incredibly slow. That actually puzzles me because in the data sheets they say that performance is increased if you send in multiples of the transfer size. Maybe they only meant an exact multiple?
Note, I increased the USB timeout to 250ms so that any delays would be obvious. Also, I ran it at 62500 Baud so to get 16*62500 (1M) because that's what I need for my hardware connected to the FT232. Although I've read that the clock on the FT232 is not accurate.
Here are the relevant FTDI docs:
https://www.ftdichip.com/Support/Documents/AppNotes/AN232B-04_DataLatencyFlow.pdf,
https://www.ftdichip.com/Support/Documents/AppNotes/AN232B-03_D2XXDataThroughput.pdf
Also note that the rates is bytes rates because the data gets output to 8 pins simultaneously.
Let me know if I could have made the code better. Here's the computer specs
Code C++ - [expand] |
1
2
3
4
| Windows 7 32bit. 2GB RAM - Intel® Core™2 CPU 6400 @ 2.13GHz 2.13 GHz
Windows 7 64bit. 8GB RAM - Intel® Core™ i7 CPU 860 @ 2.8 GHz 2GHz
ftd2xx.dll - 32bit (for both) 2.08.14
Compiled with VC++ 2010, release version |
Here's the short version of the code
Code C++ - [expand] |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| for (int tr= 1;tr<=MAX_PACKETS;++tr) // For each transfer size from 1*64 to MAX_PACKETS*64 (64Kb)
{
FT_SetUSBParameters(ftHandle, tr*PACKET_SIZE, 0);
Sleep(50);
// Write in multiples of the transfer size, max 50 multiples or 3 multiples for trasnfer size of MAX_PACKETS*64
int mult= 1;
for (;mult<2 && mult*tr<=3*MAX_PACKETS;++mult)
{
dStart= cTimer.Seconds();
// Replicate 50 times
for (int i= 0;i<25;++i)
{
dStart= cTimer.Seconds();
FT_Write(ftHandle, tx, mult*tr*DATA_PER_PACKET, &BytesWritten);
dMid= cTimer.Seconds();
FT_Read(ftHandle,rx,mult*tr*DATA_PER_PACKET,&RxBytes);
dEnd= cTimer.Seconds();
dWrite[i]= dMid-dStart;
dRead[i]= dEnd-dMid;
dTotal[i]= dEnd-dStart;
}
}
Sleep(50);
} |
Do you think that serial mode can top this?
Matt