Solved

Taking time measurements

Posted on 2000-02-22
8
205 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
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 132
Installshield for Embarcadero EX 10.1 Berlin 4 42
Abstract Express Replacement Software 12 28
How do i run a c++ file? 15 31
Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

803 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