Solved

Log time needed for process

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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