Skip to content

Instantly share code, notes, and snippets.

@amnuts

amnuts/warm.php

Last active Apr 27, 2021
Embed
What would you like to do?
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