Skip to content

Instantly share code, notes, and snippets.

@amnuts
Last active April 27, 2021 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amnuts/756d8985756278a403221494d9c0bfc5 to your computer and use it in GitHub Desktop.
Save amnuts/756d8985756278a403221494d9c0bfc5 to your computer and use it in GitHub Desktop.
Fake pre-warm op-cache files for testing https://github.com/amnuts/opcache-gui
<?php
$nums = range(0, 5000);
foreach ($nums as $i) {
$path = __DIR__."/files/c{$i}.php";
if (file_exists($path)) {
break;
}
file_put_contents($path, "<?php\n\nfunction c{$i}() { return {$i}; }\n\n");
}
foreach (range(0, 100) as $r) {
$rand = array_rand($nums, 100);
foreach ($rand as $i) {
$func = "c{$i}";
if (!function_exists($func)) {
require __DIR__ . "/files/c{$i}.php";
}
echo $func();
}
echo "\n";
}
echo 'Done';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment