harisnshaw
asked on
Measuring time diffrence in micro seconds
How do i measure time diffrence of micro seconds in turbo C++. The time.h can find max diffrence in ms only.
QueryPerformanceXXX will not be callable thru Turbo C++ i think , one way is to use clock()
clock_t start, finish;
double duration;
start = clock();
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
to get into microseconds multiply it by 10^6. This may work out to be an approximation.. code may not be portable !!!
clock_t start, finish;
double duration;
start = clock();
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
to get into microseconds multiply it by 10^6. This may work out to be an approximation.. code may not be portable !!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
clock() actually returns the amount of elapsed cpu time the calling processed used. Of course, if you're running this on just a DOS machine, it will be good enough. If, however, you're just in a DOS window, your results will very since the OS will likely suspend your process periodically to turn the cpu over to other processes.
biostime is a good option (as is INT 0x1A) - just keep in mind that they are definitely not portable. But I don't imagine that will be an issue here.
biostime is a good option (as is INT 0x1A) - just keep in mind that they are definitely not portable. But I don't imagine that will be an issue here.
Then use QueryPerformanceCounter to get the number of ticks. Then call QueryPerformanceCounter again to get the number of ticks at some later point in time. Then subtract to get the difference.