diff options
| author | cvs2svn <cvs2svn@FreeBSD.org> | 2002-02-04 19:23:42 +0000 |
|---|---|---|
| committer | cvs2svn <cvs2svn@FreeBSD.org> | 2002-02-04 19:23:42 +0000 |
| commit | b3ea8abeca50df2e24167770d1e7484f1f877a7d (patch) | |
| tree | f52b0378ac88b8ff9690c4e21a65813ff1177ed1 /tools/test/devrandom/stat.8bit | |
| parent | 9164545f1ea589d7d2f682fd09efd4fa85fd3480 (diff) | |
Notes
Diffstat (limited to 'tools/test/devrandom/stat.8bit')
| -rw-r--r-- | tools/test/devrandom/stat.8bit | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/test/devrandom/stat.8bit b/tools/test/devrandom/stat.8bit new file mode 100644 index 000000000000..03fdbdd5b39d --- /dev/null +++ b/tools/test/devrandom/stat.8bit @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +# +# Perform primitive binning into 8-bit bins (take 8 bits of randomness +# at a time) and see if the distribution is flat. The output should be +# checked by eye - are all the numbers roughly the same? +# +# Redirect the output from this to a file - and make a cup of coffee while +# it runs. This program is a CPU Hog! +# +# $FreeBSD$ +# + +for ($i = 0; $i < (1024*32); $i++) { + open(BIN, "/dev/urandom") || die "Cannot open /dev/urandom - $!\n"; + $len = sysread(BIN, $a, 256); + close(BIN); + if ($len > 0) { + for ($j = 0; $j < $len; $j++) { + $k = unpack("C", substr($a, $j, 1)); + $bin[$k]++; + } + } +} + +for ($i = 0; $i < 256; $i++) { + printf("%.2X ", $bin[$i]); +} +printf "\n"; |
