Didn't find your answer? Ask the community — no account required.
I
Isaac Bosompem
Why do you need a wrapper? Those API functions are very simple. The code will be really small. The QueryPerformanceFrequency gives you the frequency of the performance counter on the system and I believe it takes a pointer to a LARGE_INTEGER structure.
The QueryPerformanceCounter takes one parameter, a pointer to a LARGE_INTEGER structure. You use that to time your loops and the like. Of course, continually polling the Performance Counter for anything greater than or equal to ms resolution is not a good practice. This will use up 100% CPU needlessly and will be enough for most x86 CPU's to heat up quite rapidly.
printf ("\t Creat Process timing : %.9f micro sec \n ",p3);
Does it seem to be meaningful. If not could you please tell me how to do it.
Hari
Isaac Bosompem wrote:
I
Isaac Bosompem
This function looks decent but it is using the RDTSC and not the performance counter. Also you seem to be putting a fixed frequency into the structure. Do not do this. Detect the processor frequency. To get a rough sampling of the processor clock frequency, sample the TSC using the RDTSC instruction, save it, do a Sleep(1000) API call and then sample it again and simply calculate the difference. You can do it multiple times to increase the accuracy of course.
This looks alright too, but again using the time stamp counter.
The way you are using the TSC is meaningful. It's just not a good idea to use the TSC or performance counter to time periodic events in the ms resolution.
-Isaac
H
Hari
Kindly send me the source code for the same.
Isaac Bosompem wrote:
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.