Solved

Log time needed for process

Posted on 2000-04-14
3
186 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
  • 2
3 Comments
 

Author Comment

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

Accepted Solution

by:
chensu earned 50 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now