Hello, I want to measure the time my function use to execute. I was trying to use time() and clock() from time.h but it only return it in seconds. How can I measure it in miliseconds?
You could use GetTickCount or timeGetTime. These functions don't account for context switches though. If you want to get only the time spent executing your code you should use GetThreadTimes. Call it once before your function and again after your function. Subtract the old kernel time from the new kernel time and the old user time from the new user time then add the differences to get the total time.
//if you want it in milliseconds, just multiply timeElapsed by 1000.
This will lose precision and give you milliseconds rounded to whole seconds, so 1000, 2000, 3000 and nothing in-between.
The code is also mixing units which will be confusing - at (1) you have ticks stored in a clock_t, at (2) you have seconds in a clock_t. Consistency is important.