l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
January 6: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2002 May 15 14:23

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] random number question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] random number question



Pete,

- Could you explain you want in the way of random numbers?

  (reproducible or not, how many over the life of the program, how long
  the program runs, etc...)


On Wed, May 15, 2002 at 12:16:00PM -0700, Peter Jay Salzman wrote:
> begin msimons@moria.simons-clan.com <msimons@moria.simons-clan.com> 
> > open up the /dev/urandom device and read bytes from there... from read
> > to read you will get randomized stuff.
> 
> i remember, but reading a file is fine for setting a seed (that's what i
> do) but for generating a random number, it can be unsuitable.  a monte
> carlo simulation needs between 100,000 and 100,000,000 random numbers.
> reading a file for all those numbers would be prohibitive.

  If there is a need for true random numbers and then /dev/urandom isn't 
bad at all... even for large numbers of fetches.

  Reading is about 25 times slower... but if any significant CPU work being 
done with the random numbers after they are fetched, then the 25 times
slower will be lost in the noise.

    TTFN,
      Mike


  It wouldn't be hard to provide an interface that mimics the srand/rand
interface so that at link time you pick if you want true random or pseudo
random.


Following times on a pentium 100 ...

call rand:
  parent reporting 1048576 randoms fetched in 1.472942 seconds
        Command being timed: "./rand"
        User time (seconds): 1.27
        System time (seconds): 0.01
        Percent of CPU this job got: 85%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.49

/dev/urandom:
  parent reporting 1048576 randoms fetched in 35.903687 seconds
        Command being timed: "./read"
        User time (seconds): 0.01
        System time (seconds): 30.72
        Percent of CPU this job got: 85%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:35.92

/dev/zero:
  parent reporting 1048576 randoms fetched in 0.090543 seconds
        Command being timed: "./zero"
        User time (seconds): 0.01
        System time (seconds): 0.07
        Percent of CPU this job got: 72%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.11

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.