X-Git-Url: http://git.squeep.com/?p=reservoir_sample;a=blobdiff_plain;f=test%2Fvalidate-statistics.sh;fp=test%2Fvalidate-statistics.sh;h=0df8fb1815b577d7da4af84c4077c4940174b15b;hp=0000000000000000000000000000000000000000;hb=ee831dbcdf31c3d1205bc321a8bdbeeb151abe19;hpb=c8ff35a649a7df3d400221fc76131bff195a158b diff --git a/test/validate-statistics.sh b/test/validate-statistics.sh new file mode 100755 index 0000000..0df8fb1 --- /dev/null +++ b/test/validate-statistics.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# + +# Collects and counts the output of multiple invocations over the same input stream. +# Counts ought to be roughly the same, based on quality of random source. + +invoke_n() { + seq $1 | ./reservoir_sample -r /dev/random 2>/dev/null +} + +invoke_n_i() { + local i=0 + while [ $i -lt $2 ] + do + invoke_n $1 + ((i++)) + local note=`expr $i % 1000` + if [ $note -eq 0 ] + then + echo "... iteration $i of $2" 1>&2 + fi + done +} + +tally_n_i() { + invoke_n_i $1 $2 | sort -n | uniq -c +} + +tally_n_i 20 10000