Skip to content

Instantly share code, notes, and snippets.

@kmark
Last active January 30, 2019 09:19
Show Gist options
  • Save kmark/87d8c43839219fddadadd69f1bbf94fb to your computer and use it in GitHub Desktop.
Save kmark/87d8c43839219fddadadd69f1bbf94fb to your computer and use it in GitHub Desktop.
Does about 15 MiB/s on my machine
#!/usr/bin/env php
<?php
mt_srand(random_int(PHP_INT_MIN, PHP_INT_MAX));
while (true) {
$a = [];
for ($i = 0; $i < 10000; $i++) {
$a[] = mt_rand_short();
}
echo pack("s*", ...$a);
}
function mt_rand_short() : int {
return mt_rand(-2**15, 2**15 - 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment