Last active
October 7, 2020 12:49
-
-
Save mrunkel/3054b0d8d6b9085744ae05837518c0b9 to your computer and use it in GitHub Desktop.
A little PHP function to generate a delay that is between 0.1 and 5 with an average of .47 over time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function delay(): float | |
{ | |
$quicker = array_fill(0, 50, .1); | |
$quick = array_fill(0, 50, .2); | |
$average = array_fill(0, 60, .5); | |
$slow = array_fill(0, 7, 1.5); | |
$slower = array_fill(0, 5, 2.5); | |
$slowest = array_fill(0, 3, 5); | |
$delayTable = array_merge($quicker, $quick, $average, $slow, $slower, $slowest); | |
return $delayTable[random_int(0, count($delayTable) - 1)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment