how to calculate the starting and end time of switch in VC++ can anyone please help me to solve this?
+1
A:
See the clock() function
#include <time.h>
clock_t start = clock();
//...
//do something
double total = (double) (clock() - start) / CLOCKS_PER_SEC;
here the total variable holds the time (in seconds) the do something part takes to complete.
Note that if you need more accurate timing you can use QueryPerformanceCounter and QueryPerformanceFrequency functions, however they specific to Windows platform.
Can
2009-07-30 10:48:25
+1
A:
If you're trying to calculate how long the switch took to execute try calling gettickcount before and then after and subtract the two values should give you the delay in milliseconds.
Rich
2009-07-30 22:37:23