From owner-freebsd-questions Tue May 15 1:40:19 2001 Delivered-To: freebsd-questions@freebsd.org Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by hub.freebsd.org (Postfix) with ESMTP id B025237B43C; Tue, 15 May 2001 01:40:13 -0700 (PDT) (envelope-from phk@critter.freebsd.dk) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.3/8.11.3) with ESMTP id f4F8dup30517; Tue, 15 May 2001 10:39:57 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: dleimbac@earthlink.net Cc: freebsd-questions@FreeBSD.ORG, arch@FreeBSD.ORG Subject: Re: Gettimeofday Again... In-Reply-To: Your message of "Mon, 14 May 2001 22:39:32 CDT." <200105150337.UAA19677@gull.mail.pas.earthlink.net> Date: Tue, 15 May 2001 10:39:56 +0200 Message-ID: <30515.989915996@critter> From: Poul-Henning Kamp Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <200105150337.UAA19677@gull.mail.pas.earthlink.net>, dave writes: > > >Well I have been on the IRC in and out of mail list archives and cannot get >a good answer to this question... > >Why does gettimeofday perform so poorly on FreeBSD vs the same hardware on >Linux 2.4.2? > >---SNIP----- >#include >#include > >int main() { > struct timeval tv1, tv2, tv3; > > gettimeofday(&tv1, 0); > gettimeofday(&tv2, 0); > gettimeofday(&tv3, 0); > > printf("Time 1 %d:%d\n", tv1.tv_sec, tv1.tv_usec); > printf("Time 2 %d:%d\n", tv3.tv_sec, tv3.tv_usec); > >} >----SNIP----- > >I get anywhere from 14usec to 17usec just for the call to gettimeofday. > >On the 2.4.2 linux kernel its something like 3usec. > >I just want to know why we are so much slower. Because we havn't particularly optimised it. If we want to, we can get to the point where a machine with a usable TSC doesn't even have to enter the kernel. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message