I'm using php 7.1.0. The script I'm benchmarking is this one:
$myclass = new MyClass();
$t1 = microtime(true);
myfunction();
echo microtime(true)-$t1;
$t2 = microtime(true);
myfunction();
echo microtime(true)-$t2;
Results are:
~30 milliseconds the first time
~0.7 milliseconds the second time.
And this is valid not only for the second time but also for the following ones.
I'm asking why there is such difference between the first execution and the following ones. I think it's a problem of loading the functions in memory, once loaded it is as it should be but I also suppose that ~30ms are too much to load the function in memory.
Other informations:
Thank you