?
Solved

Log time needed for process

Posted on 2000-04-14
3
Medium Priority
?
199 Views
Last Modified: 2010-04-02
Hi,

Using Borland cpp Builder 4.x

I want to log the time needed for a certain process.

I tried :

SYSTEMTIME Time ;
GetSystemTime(&Time) ;
DWORD Seconds = (Time.wSecond + (Time.wMinute * 60) + (Time.wHour * 60 * 60))

Further down the code, after the process is finished I do this again and see what the difference is.

The question.
Is there an alternative and maybe faster way ??
Faster in the sense : more accurate ?

Is the above mentioned method effecient enough or is it system dependant and time consoming to get that time ??

Input is welcome.

sneeuw
0
Comment
Question by:sneeuw
[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
  • 2
3 Comments
 

Author Comment

by:sneeuw
ID: 2717873
typo :
consoming = consuming
;-)
0
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 2718094
You may use the GetTickCount or timeGetTime functions. timeGetTime is more accurate.

"Windows NT/2000: The default precision of the timeGetTime function can be five milliseconds or more, depending on the machine. You can use the timeBeginPeriod and timeEndPeriod functions to increase the precision of timeGetTime. If you do so, the minimum difference between successive values returned by timeGetTime can be as large as the minimum period value set using timeBeginPeriod and timeEndPeriod. Use the QueryPerformanceCounter and QueryPerformanceFrequency functions to measure short time intervals at a high resolution,

Windows 95: The default precision of the timeGetTime function is 1 millisecond. In other words, the timeGetTime function can return successive values that differ by just 1 millisecond. This is true no matter what calls have been made to the timeBeginPeriod and timeEndPeriod functions."

See the following article for how to use the QueryPerformanceCounter function.

Win32 Multithreading Performance
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/techart/msdn_threadli.htm
0
 

Author Comment

by:sneeuw
ID: 2727228
Seems to work OK.
Thanks !

sneeuw
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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