3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testsize = 1000*100; $bucketcount = 16; $buckets = array(); // Initialize buckets for ($i = 0; $i < $bucketcount; $i++) { $buckets[$i] = 0; } // Run the test for ($i = 0; $i < $testsize; $i++) { $n = ord(openssl_random_pseudo_bytes(1)); $buckets[$n % $bucketcount]++; // Here is our modulo operation } echo "Expected in each bucket: " . ($testsize / $bucketcount) . "\n"; print_r($buckets);

preferences:
47.5 ms | 402 KiB | 5 Q