For those that care , here is a C++ code snippet to show
how to use the high performce timers built into the computers
(if available). If the timers are not availble then use the standard
lower resolution timer.
Later,
Paul Kohut
#include "time.h"
.
.
.
// Perform timings using the built in high frequency timers, if available
LARGE_INTEGER lfreq;
if(QueryPerformanceFrequency(&lfreq)) {
acutPrintf("\nTimings performed by high frequency counter.");
LARGE_INTEGER lstart, lfinish;
double ldiff;
if(nLength) {
QueryPerformanceCounter(&lstart);
// begin timed process
if(GetLayerList(&idArray, nLength, ss)) {
QueryPerformanceCounter(&lfinish);
ldiff = lfinish.QuadPart - lstart.QuadPart;
acutPrintf("\n%.8f seconds to process %i entities and %i layers",
ldiff / lfreq.QuadPart, nLength, idArray.length());
QueryPerformanceCounter(&lstart);
// begin timed process
if(LayersOff(&idArray)) {
QueryPerformanceCounter(&lfinish);
ldiff = lfinish.QuadPart - lstart.QuadPart;
acutPrintf("\n%.8f seconds to turn off %i layers", ldiff /
lfreq.QuadPart, idArray.length());
}
}
}
}
else { // No high frequency timers available.
// Perform timing with stanard resolution of GetTickCount, see
documentation
DWORD start, finish;
acutPrintf("\nTimings performed by GetTickCount, see documentation for
frequency.");
start = GetTickCount();
if(GetLayerList(&idArray, nLength, ss)) {
finish = GetTickCount();
acutPrintf("\n%.8f seconds to process %i entities and %i layers",
0.001 * (finish - start), nLength, idArray.length());
start = GetTickCount();
if(LayersOff(&idArray)) {
finish = GetTickCount();
acutPrintf("\n%.8f seconds to turn off %i layers", 0.001 * (finish -
start), idArray.length());
}
}
}