Created
June 23, 2017 02:57
-
-
Save vitqst/4b33fcbee6f908dc9241a9c152f3a66c to your computer and use it in GitHub Desktop.
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
<?php | |
generalData(); | |
function generalData() | |
{ | |
$id = 26; | |
$max = 100000000000000000000; | |
$startMemory = memory_get_usage(); | |
$create = function () use ($max, $id) { | |
$data = []; | |
for ($i = 0; $i < $max; $i++) { | |
$item = []; | |
$item[] = $id; | |
$item[] = generateRandomString(10); | |
yield $item; | |
} | |
}; | |
$data = $create(); | |
echo '<br>'; | |
echo '<br>'; | |
echo memory_get_usage() - $startMemory, ' bytes'; | |
exit; | |
} | |
function generateRandomString($length = 10) | |
{ | |
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
$charactersLength = strlen($characters); | |
$randomString = ''; | |
for ($i = 0; $i < $length; $i++) { | |
$randomString .= $characters[rand(0, $charactersLength - 1)]; | |
} | |
return $randomString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment