From owner-freebsd-hackers@FreeBSD.ORG Tue Dec 21 19:16:04 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 900C316A4CE for ; Tue, 21 Dec 2004 19:16:04 +0000 (GMT) Received: from smtp-out.hotpop.com (smtp-out.hotpop.com [38.113.3.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E3F443D55 for ; Tue, 21 Dec 2004 19:16:04 +0000 (GMT) (envelope-from mastah@phreaker.net) Received: from phreaker.net (kubrick.hotpop.com [38.113.3.103]) by smtp-out.hotpop.com (Postfix) with SMTP id C277EB173D6 for ; Tue, 21 Dec 2004 19:15:56 +0000 (UTC) Received: from master.phreaker.net (dialup-as2-45.ilca.ru [82.179.161.45]) by smtp-1.hotpop.com (Postfix) with ESMTP id 4E78C1A0218 for ; Tue, 21 Dec 2004 19:15:44 +0000 (UTC) Message-Id: <6.2.0.7.1.20041221221529.021bb7d0@pop.phreaker.net> X-Sender: mastah@phreaker.net@pop.phreaker.net X-Mailer: QUALCOMM Windows Eudora Version 6.2.0.7 (Beta) Date: Tue, 21 Dec 2004 22:15:33 +0300 To: hackers@freebsd.org From: Castl Troy Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-HotPOP: ----------------------------------------------- Sent By HotPOP.com FREE Email Get your FREE POP email at www.HotPOP.com ----------------------------------------------- Subject: calibrating time X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Dec 2004 19:16:04 -0000 Hello hackers, Just want to ask people here who have time to run my program and answer me back output from it. Thanks! ===== #include #include #include #include #include int main(int argc, char **argv) { u_int i, avg, totaldiff = 0; u_int diff[10]; struct timeval pold, pcur; fprintf(stderr, "Examining sleep()\n"); for(i=0; i<10; i++) { gettimeofday(&pold, NULL); sleep(1); gettimeofday(&pcur, NULL); fprintf(stderr, "Pass %2d [ diff: %3lu.%-6lu second(s) ]\n", i, pcur.tv_sec - pold.tv_sec, pcur.tv_usec - pold.tv_usec); diff[i] = pcur.tv_usec - pold.tv_usec; } for(i=0; i<10; i++) totaldiff+=diff[i]; avg = totaldiff / 10; fprintf(stderr, " -- average diff: %5u microsecond(s)\n", avg); fprintf(stderr, "\nExamining usleep()\n"); for(i=1;i<11; i++) { gettimeofday(&pold, NULL); usleep(1 * 1000 * 1000); gettimeofday(&pcur, NULL); fprintf(stderr, "Pass %2d [ diff: %3lu.%-6lu second(s) ]\n", i, pcur.tv_sec - pold.tv_sec, pcur.tv_usec - pold.tv_usec); diff[i] = pcur.tv_usec - pold.tv_usec; } for(i=0; i<10; i++) totaldiff+=diff[i]; avg = totaldiff / 10; fprintf(stderr, " -- average diff: %5u microsecond(s)\n", avg); exit(0); }