Though following code sequence is safe currently (even w/o BGL):
[dragonfly/netmp.git] / tools / test / devrandom / stat.16bit
blob2470101ea01b7ab92f5da026962bc3f593830716
1 #!/usr/bin/perl
4 # Perform primitive binning into 16-bit bins (take 16bits of randomness
5 # at a time) and see if the distribution is flat. The output should be
6 # checked by eye - are all the numbers roughly the same?
8 # Redirect the output from this to a file - and go to the movies while
9 # it runs. This program is a CPU Hog!
11 # $FreeBSD: src/tools/test/devrandom/stat.16bit,v 1.4 1999/08/28 00:54:24 peter Exp $
12 # $DragonFly: src/tools/test/devrandom/stat.16bit,v 1.2 2003/06/17 04:29:11 dillon Exp $
15 for ($i = 0; $i < (1024*64); $i++) {
16 open(BIN, "/dev/urandom") || die "Cannot open /dev/urandom - $!\n";
17 $len = sysread(BIN, $a, 512);
18 close(BIN);
19 if ($len > 0) {
20 for ($j = 0; $j < $len; $j += 2) {
21 $k = unpack("S", substr($a, $j, 2));
22 $bin[$k]++;
27 for ($i = 0; $i < 1024*64; $i++) {
28 printf("%.2X ", $bin[$i]);
30 printf "\n";