examples/heap_push.rb in compsci-0.3.0.1 vs examples/heap_push.rb in compsci-0.3.1.1
- old
+ new
@@ -4,15 +4,21 @@
include CompSci
runtime = (ARGV.shift || "3").to_i
puts <<EOF
+
#
-# 3 seconds worth of pushes
+# #{runtime} seconds worth of Heap pushes
#
EOF
+
+# pregenerate a sequence of random numbers
+# every NUMBERWANGth request, shift the sequence and push a new random
+# this should mitigate random number generation from interfering with timing
+# while also mitigating any chance of cyclic behavior
RANDMAX = 1_000
NUMBERWANG = 1_000
NUMS = (0..(RANDMAX - 1)).to_a.shuffle
def number(num)