X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <4783B96D.9060709@huarp.harvard.edu> Date: Tue, 08 Jan 2008 12:57:01 -0500 From: Norton Allen User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Does clock() work? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass (ent.arp.harvard.edu: 10.0.0.122 is authenticated by a trusted mechanism) 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 I am trying to write a benchmark application, and figured I'd use clock() for sub-second resolution timing, but I got non-sensical results. I check the cygwin archives, but the only mention I saw was that clock() didn't work on Win98. Here's my test code, chktime.c: #include #include #include int main( int argc, char **argv ) { clock_t cur_time, cps = CLOCKS_PER_SEC; int i; printf( "CLOCKS_PER_SEC = %ld\n", cps ); for ( i = 0; i < 8; i++ ) { sleep(1); cur_time = clock(); printf( "clock() = %ld\n", cur_time ); } return 0; } and here's the output I get: Cygwin> ./chktime CLOCKS_PER_SEC = 1000 clock() = 171 clock() = 171 clock() = 171 clock() = 171 clock() = 171 clock() = 171 clock() = 171 clock() = 171 Cygwin> I would expect the clock() values to increase by approximately 1000 on each iteration. (Yes, the sleep() seems to be working, as the lines come out at about 1 Hz.) Is this a known problem? Do others get this result, or do I have a corrupted library? -Norton Allen -- 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/