After almost an hour of debugging some completely unreasonable execution times for requests that should have taken milliseconds, I found out that calling
$path = realpath("//localhost/mywebsite/config/some_config_file.yml");
would take almost 30 seconds when executed the first time and take milliseconds later on (for the same string).
While I was able to remove the line (it was unnecessary anyway, please don't judge) and thus remove the bug, I would still like to know what happened as I'd like to grow as a developer.
- What causes realpath() to take 30 seconds?
- Why the much shorter time on subsequent requests? Is this OPcache using a precompiled value?
FYI: The requests were done on my local machine with xdebug activated. PHP 7.2, Win 10 and Apache.
Aucun commentaire:
Enregistrer un commentaire