Solved

Taking time measurements

Posted on 2000-02-22
8
209 Views
Last Modified: 2013-11-15
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>
0
Comment
Question by:Lescha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 30 total points
ID: 2547745
You can easily do this by calling 'GetTickCount()'
0
 
LVL 86

Expert Comment

by:jkr
ID: 2547753
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
 
LVL 22

Expert Comment

by:nietod
ID: 2547837
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 86

Expert Comment

by:jkr
ID: 2547952
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
 
LVL 22

Expert Comment

by:nietod
ID: 2548104
I didn't get an e-mail about my comment either.  :-)

I got yours though.
0
 
LVL 1

Author Comment

by:Lescha
ID: 2551632
Thanks, "jkr", "nietod".

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

Lescha
0
 
LVL 86

Expert Comment

by:jkr
ID: 2551918
>>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
 
LVL 1

Author Comment

by:Lescha
ID: 2557251
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question