Skip to content

Instantly share code, notes, and snippets.

@vitqst
Created June 23, 2017 02:57
Show Gist options
  • Save vitqst/4b33fcbee6f908dc9241a9c152f3a66c to your computer and use it in GitHub Desktop.
Save vitqst/4b33fcbee6f908dc9241a9c152f3a66c to your computer and use it in GitHub Desktop.
<?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