From owner-freebsd-current Sat Oct 5 14:57:34 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA10833 for current-outgoing; Sat, 5 Oct 1996 14:57:34 -0700 (PDT) Received: from sovcom.kiae.su (sovcom.kiae.su [193.125.152.1]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id OAA10814; Sat, 5 Oct 1996 14:57:20 -0700 (PDT) Received: by sovcom.kiae.su id AA23425 (5.65.kiae-1 ); Sun, 6 Oct 1996 00:42:15 +0300 Received: by sovcom.KIAE.su (UUMAIL/2.0); Sun, 6 Oct 96 00:42:15 +0300 Received: (from ache@localhost) by nagual.ru (8.7.6/8.7.3) id BAA06368; Sun, 6 Oct 1996 01:39:30 +0400 (MSD) Message-Id: <199610052139.BAA06368@nagual.ru> Subject: Re: I plan to change random() for -current (was Re: rand() and random()) In-Reply-To: <199610051856.EAA30329@godzilla.zeta.org.au> from "Bruce Evans" at "Oct 6, 96 04:56:27 am" To: bde@zeta.org.au (Bruce Evans) Date: Sun, 6 Oct 1996 01:39:29 +0400 (MSD) Cc: bde@zeta.org.au, current@FreeBSD.org, freebsd-hackers@FreeBSD.org, joerg_wunsch@uriah.heep.sax.de From: =?KOI8-R?Q?=E1=CE=C4=D2=C5=CA_=FE=C5=D2=CE=CF=D7?= (Andrey A. Chernov) Organization: self X-Class: Fast X-Mailer: ELM [version 2.4ME+ PL28 (25)] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > This is much slower than the current rand() or random(). On a P133, > measured over 10^7 calls to statically linked libraries: You forget the fact that srandom() called only _once_ (usually), so speed is unimportant here. TYPE_0 case in random() is very rare thing too, it seems nobody use it. > Perhaps make this a subroutine to avoid duplication and allow easy > changing. Division takes 10-20 times longer than a subroutine call > on Pentiums. We can't relay on Pentium times in machine-independent code. I am thinking about making it #define or inline, which one is better? -- Andrey A. Chernov http://www.nagual.ru/~ache/