Previously, we had been using NetDuino Plus 2 for our application, which is a single board module with 168Mhz processor.
Now, we are migrating our code from that board to FezHydra. Main reasons that motivated us to try this migration, mainly was higher amount of RAM, flash memory on FezHydra and wider support of NetMF libraries by its firmware.
In our application, boards receive some data through serial ports, run a series of operations on them and return the results. However, we noticed a considerable turnaround time between these two boards. While it took 3-4 milliseconds for Netduino board to return the result, FezHydra needed 30-31 milliseconds to return the result by performing the same operations on the same data.
Thus, we ran a very simple test to confirm the delay on FezHydra board.
The below are the snippets for FezHydra and Netduino board respectively for the purpose of testing. There was no data on port so the loop basically runs only the check (if command).
[em][/em]
rs232.Configure(19200, GT.SocketInterfaces.SerialParity.None, GT.SocketInterfaces.SerialStopBits.One, 8, GT.SocketInterfaces.HardwareFlowControl.NotRequired);
byte[] temp;
DateTime dt1 = DateTime.Now;
for (int i = 0; i < 100000; i++)
if (rs232.Port.BytesToRead > 0)
{
temp = new byte[rs232.Port.BytesToRead];
rs232.Port.Read(temp, 0, temp.Length);
}
Debug.Print(((DateTime.Now.Ticks - dt1.Ticks) / (TimeSpan.TicksPerMillisecond)).ToString());
[em][/em]
SerialPort rs232 = new SerialPort("COM1",19200);
byte[] temp;
DateTime dt1 = DateTime.Now;
for (int i = 0; i < 100000; i++)
if (rs232.Port.BytesToRead > 0)
{
temp = new byte[rs232.Port.BytesToRead];
rs232.Port.Read(temp, 0, temp.Length);
}
Debug.Print(((DateTime.Now.Ticks - dt1.Ticks) / (TimeSpan.TicksPerMillisecond)).ToString());
Basically, codes were the same. But, the results were different. The output by NetDuino is 3484 msec, while by FezHydra 16278 msec.
Now, my question is that what could cause this considerable delay? Is that because of Gadgeteer modules and the way they have been implemented in GHI Firmware?
I also suspect that there are some threads running in the background like garbage collection, etc. that could affect processing performance. If this is true, is there anyway to disable them and run them manually at desired times?
[em]Update (1) 10/10/2014:[/em]
Based on @ Architect’s suggestion, I ran the experiment by a console application on Hydra board and the results went down to 7950 to 7990 msec range, but still higher than NetDuino’s results.