Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 22nd, 2004, 04:08 AM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default timing issue

Im trying to clock the time taken by two programs to execute, one uses win32 api's and other uses MFCs...I need to find the time in milli seconds or even better in micro seconds....
any idea how i shud go about it?
time function returns only in seconds(i need thousandth of a second also)

I am new to C programming so do help me.some probs may be very easy to ull..

thnx & regards
Ritesh
Reply With Quote
  #2 (permalink)  
Old September 22nd, 2004, 05:08 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Simply time is divided by 1000 to get time microseconds


Numan
--------------------------------------------------
Love is the most precious thing of this world. So find it and grab it!
Reply With Quote
  #3 (permalink)  
Old September 22nd, 2004, 07:10 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to rikelme
Default

Hi,

There is a function:
clock_t clock(void);
in <time.h> which eturns number of clock ticks since process start, and there si a macro called CLK_TCK who defines the relation betwen clock tick and second (clock ticks per second).
So, if you want to calculate time elapsed betwen two events:


float timeElapsed;
clock_t clock0, clock1;
//event 1 happend:
clock0 = clock();
//time is running....
//event 2 happend:
clock1 = clock();
//time elapsed in seconds:
timeElapsed = (clock1 - clock0)/CLK_TCK;
/*just devide it with 1.000 to get it in miliseconds or
with 1.000.000 to get it in microseconds */

Try it, I think it will work :)


Miroslav Ristic
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Get Difference timing Between Two Time smmedicals Pro VB Databases 1 August 11th, 2008 01:57 PM
Remoting timing out after 2 minutes BrainWave ASP.NET 2.0 Professional 0 August 13th, 2007 06:54 AM
HTTPWebRequest GetResponse Timing-out amahajan .NET Web Services 0 July 13th, 2005 11:54 AM
database timing gmoney060 BOOK: Beginning ASP 3.0 1 June 2nd, 2004 06:52 AM
Stored procedure timing out pankaj_daga SQL Server 2000 4 January 2nd, 2004 03:53 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.