Quote:
Originally Posted by vignesh1988i
i need to find out the processing or operating time in milliseconds or in nanoseconds for the instructions or for the whole process!!!!!
|
Measuring the time in nanoseconds, or measuring the time of a few instructions, is not meaningful. CPUs are pipelined enough that there is no useful meaning to the elapsed time of just a few instructions.
I think the finest granularity you can measure is with rdtsc (you can find more info easily with a google search).
Quote:
for eg :
i need to calculate the time taken to execute :
|
Despite the example, I don't have much of a guess at what you're trying to do. If you explain the purpose, maybe you'll get better help.
Quote:
if( n%2==0) // i need the processing time in milliseconds or in nano
|
Does that mean you want the time for just that test and the conditional branch? That is too little to measure. If you tried to use rdtsc to measure that, the attempt to measure would greatly change the thing you're trying to measure (you could measure the time of one rdtsc plus the code you want to measure. But if you subtract the time of one rdtsc from that result, the answer might not be close to what the code you're measuring would have taken without the rdtsc).
If the code you want is executed
many times in the course of a
very long program execution, then it could be sampled with oprofile to get a statistically valid estimate of an execution time that might be accurate to a nanosecond in extreme cases (normally oprofile doesn't give you close to nanosecond accuracy).