Solved

Log time needed for process

Posted on 2000-04-14
3
187 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create string splitting user defined function in C++ 23 289
Lambda for random numbers problem 7 106
FMX enumerated colours 2 84
FMX TCameraComponent Problem 2 48
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

929 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

14 Experts available now in Live!

Get 1:1 Help Now