Skip to content

Instantly share code, notes, and snippets.

Last active Apr 27, 2021
What would you like to do?
Fake pre-warm op-cache files for testing
$nums = range(0, 5000);
foreach ($nums as $i) {
$path = __DIR__."/files/c{$i}.php";
if (file_exists($path)) {
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