delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/01/18:17:25

Date: Sun, 1 Aug 1999 11:56:46 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Dan Gold <TedMat AT CoastNet DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: how about "more" random ? SPEED???
In-Reply-To: <199907311044.GAA17866@delorie.com>
Message-ID: <Pine.SUN.3.91.990801115054.20304Y-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, 4 Jan 1980, Dan Gold wrote:

> I was wondering about how fast rand actually executes, Is it something to
> consider when using it alot or is it virtually unnoticable?

It depends on what your program does otherwise.

To get an idea where your program spends most of its time, you should 
profile it.  DJGPP includes a profiler, see chapter 13 of the DJGPP FAQ 
list for more about this.  If the profiler shows that the random number 
generation takes less than 20% of program's time, it doesn't make much 
sense to try to speed up random().

> Is there anyway
> to avoid the multiplications and mods?  Is there a better alternative like
> making some kind of randomness look-up-table or something?

Random number generators is a discipline.  If you are really interested in
this, begin by reading Knuth's volume that describes random number
generators.  You might also search www.dejanews.com for articles posted by
George Marsaglia, who is one of the gurus on this issue.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019