I have been doing some timings on a firmware model that would provide multiple protocol support in a vehicle application. The reference is an existing piece of hardware.
The model uses multiple threads. Messages are moved about via queues, and threads spend most of their lives hanging on events. One end is USB and the other is CAN. The simplest exchange with the PC is the retrieval of the version string. The reference hardware processes 2000 of these actions in 4.06 seconds. The EMX model takes 21.26 seconds to do the same. I have timed various sections looking for particular bottlenecks and find the time spread pretty evenly over the entire process. However, there are two areas that jump out - the movement of information into and out of structures (using the BitConverter class I found on the forum) and the USB interaction. I hate to forego the structures, but this is about 10-20% of the time, depending on the message traffic. Any suggestions would be welcome.
As to the USB, this is harder to capture. Measuring from TX to the PC to the following RX I am seeing 7 seconds of the 21 second total. Since everything is identical at the other end of the USB wire, and the entire process can be completed in 4 seconds, it would seem that the USB interface is introducing some delays. I do have a heartbeat thread running off a 500ms sleep. The CAN task is not even started for this test. Has anyone else experienced throughput issues with USB?