X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org X-YMail-OSG: aL8eArEVM1kDu1Qisj2E4S98xqRWW31q8wBLoadGmnQ2BlwfaxRc.gadofJb5ralG1d8zqRAHOnU17ynihH8sfRCEixFVoCygDji4up12pafIUKyFxxVpw-- Message-ID: <4783D05F.5030007@sbcglobal.net> Date: Tue, 08 Jan 2008 19:34:55 +0000 From: Greg Chicares User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Does clock() work? References: <4783B96D DOT 9060709 AT huarp DOT harvard DOT edu> <4783C3D9 DOT 6020303 AT sbcglobal DOT net> <4783CBDE DOT 8070201 AT huarp DOT harvard DOT edu> In-Reply-To: <4783CBDE.8070201@huarp.harvard.edu> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 2008-01-08 19:15Z, Norton Allen wrote: > > Now, I am definitely interested in wall clock elapsed time. Is there > anything available that will give me real time at resolution greater > than one second? /tmp[0]$cat clock_test.c #include #include #include #include // gettimeofday() int main( int argc, char **argv ) { clock_t cur_time, cps = CLOCKS_PER_SEC; int i; struct timeval x; printf( "CLOCKS_PER_SEC = %ld\n", cps ); for ( i = 0; i < 8; i++ ) { sleep(1); cur_time = clock(); printf( "clock() = %ld\n", cur_time ); gettimeofday(&x, 0); printf( "gettimeofday() = %ld\n", 1000000 * x.tv_sec + x.tv_usec ); } return 0; } /tmp[0]$gcc -o clock_test.exe clock_test.c /tmp[0]$./clock_test CLOCKS_PER_SEC = 1000 clock() = 30 gettimeofday() = 210033718 clock() = 30 gettimeofday() = 211033718 clock() = 30 gettimeofday() = 212033718 clock() = 30 gettimeofday() = 213033718 clock() = 30 gettimeofday() = 214033718 clock() = 30 gettimeofday() = 215033718 clock() = 30 gettimeofday() = 216033718 clock() = 30 gettimeofday() = 217033718 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/