Taking time measurements

I need to make exact (with at least 0.01 sec) time measurements. Is there a normal function to do that, like there is "tic" and "toc" in Matlab?

If the answer involves MFC, tell me so in a comment, I will erase this question and repost it into that appropriate section.

What I mean is:

<start timer>
<make a run>
<stop timer>
LVL 1
LeschaAsked:
Who is Participating?
 
jkrConnect With a Mentor Commented:
You can easily do this by calling 'GetTickCount()'
0
 
jkrCommented:
To elaborate - a call to 'GetTickCount()' returns the number of milliseconds that have elapsed since Windows was started. So if you want to measure the amount of time a certain operation takes, use

DWORD dwBefore;
DWORD dwAfter;
DWORD dwMillisecondsElapsed;

dwBefore = GetTickCount();

// processing here...

dwAfter = GetTickCount();

dwMillisecondsElapsed = dwAfter - dwBefore;
0
 
nietodCommented:
The problem with that  (well actually with ANY solution, so no criticism of what jkr said) is that windows is a mult-tasking system so high precission timing at the application level is not possible.  If your app is suspended fir 1/2 second during the run you don't have 0.1 accuracy.  

There are things that can be done to make timing more reliable, but you will still find that it isn't perfect.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jkrCommented:
A little bit 'off topic' -  I seem to have some trouble with email notifications (haven't even been informed about nietod's comment by now), is anybody else experiencing this also?
0
 
nietodCommented:
I didn't get an e-mail about my comment either.  :-)

I got yours though.
0
 
LeschaAuthor Commented:
Thanks, "jkr", "nietod".

As to notifications: no problem here, I received them all. Maybe some temporary problem on your server, "jkr"?

Lescha
0
 
jkrCommented:
>>Maybe some temporary problem on your
>>server

I hope so - but when there's a problem, it is not due to *my* server, as it is next to me... but maybe a unreliable relay host in between...
0
 
LeschaAuthor Commented:
Both for "jkr" and "nietod" - I don't know of any other way to attract your attention to a very interesting problem I've been trying to solve for several months now. Please take a look at this question:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=10266344 

0
All Courses

From novice to tech pro — start learning today.