I'm trying to measure my response time on a serial protocol handshake by pulling QueryPerformanceCounter (QPC). My target system is a win7 on Asrock D1800b Intel Dual Core, compiling with latest version of MinGw (6.3.0-1).
In order to test QPC I have this code:
#include <windows.h>
#include <stdio.h>
void main()
{
//performance timers
LARGE_INTEGER StartingTime, EndingTime, ElapsedMicroseconds;
LARGE_INTEGER Frequency;
QueryPerformanceFrequency(&Frequency);
for (int i = 0 ; i < 10 ; i++)
{
QueryPerformanceCounter(&StartingTime);
Sleep(10); //ms
QueryPerformanceCounter(&EndingTime);
ElapsedMicroseconds.QuadPart = EndingTime.QuadPart - StartingTime.QuadPart;
ElapsedMicroseconds.QuadPart *= 1000000; //first scale up counts
ElapsedMicroseconds.QuadPart /= Frequency.QuadPart; //then convert to us
printf("elapsed=%li\n", ElapsedMicroseconds.QuadPart);
}
}
When run on the target system I get: (no other loads)
elapsed=5341
elapsed=14086
elapsed=13818
elapsed=14322
elapsed=15305
elapsed=8867
elapsed=12162
elapsed=14225
elapsed=13333
elapsed=14751
But when run on the developing system (Win10, Intel i5), I get this much consistent result
elapsed=11326
elapsed=11556
elapsed=12630
elapsed=11583
elapsed=11749
elapsed=12644
elapsed=12562
elapsed=11690
elapsed=11726
elapsed=11664
Both above results are examples of a much larger run.
the expected result is somewhere above 10000us.
So, any ideas of what it going on on the target system?