delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
From: | "Ralf Habacker" <Ralf DOT Habacker AT freenet DOT de> |
To: | "Cygwin" <cygwin AT sources DOT redhat DOT com> |
Subject: | gettimeofday() does not returns usec resolution |
Date: | Wed, 23 Jan 2002 08:20:48 +0100 |
Message-ID: | <00af01c1a3de$7af04b40$60a407d5@BRAMSCHE> |
MIME-Version: | 1.0 |
X-Priority: | 3 (Normal) |
X-MSMail-Priority: | Normal |
X-Mailer: | Microsoft Outlook 8.5, Build 4.71.2173.0 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4133.2400 |
Importance: | Normal |
Hi, for kde2 we are building a profiler lib for profiling complex c++ applications (currently found in the cvs areas of kde-cygwin.sf.net (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/kde-cygwin/profiler/) using the high resolution timer of native windows (about usec resolution). This lib could be use for easy profiling of any c++ application and libs like cygwin.dll and so on. While adding unix support (and cygwin) for this lib, I noticed, that the gettimeofday() function returns only a resolution of 10ms (the time slice resolution) but mostly other unix os returns a resolution in the usec region. I have appended a testcase for this. Has anyone address this problem already. I have looked int the cygwin and list and found the only topic http://sources.redhat.com/ml/cygwin/2001-12/msg00201.html In http://www-106.ibm.com/developerworks/library/l-rt1/ there is a detailed instruction how to use the hugh resolution counter. . $ cat timeofday.c #include <sys/time.h> int main() { struct timeval tp; long a,b; gettimeofday(&tp,0); a = ((unsigned)tp.tv_sec)*1000000+((unsigned)tp.tv_usec); printf("timestamp (us): %d\n",a); usleep(1000); gettimeofday(&tp,0); b = ((unsigned)tp.tv_sec)*1000000+((unsigned)tp.tv_usec); printf("timestamp (us): %d (diff) %d\n",b,b-a); } Ralf Habacker -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |