I'm trying to check how long it took to load my page in PHP, this means created a start and end time and checking the differences at the end of the script.
I do this with microtime and then print out how long it actually took, I want to print it out using miliseconds, so lets say it took 269 milliseconds to load, it would display the following.
Page was rendered in 269 milliseconds.
I also have an extension on my browser that displays how long the page took, is this load the extension said 82ms, now I know they can vary but I'm just putting that out there.
My page displays 0.28086708618164
but surely it can't be that low? I'm not loading any assets, images, css files or anything so the gap between the extension and PHP really shouldn't be that much, I'm hoping you guys agree...
Here is my code:
<?php declare(strict_types = 1);
define("START", microtime(true));
// execute some code...
printf("Page was rendered in %s milliseconds", (microtime(true) - START) * 1000);