i own a site with a high load cpu httpd request per minute. I’ve noticed i use “file_exists” on each httpd request. Is that function to much heavy?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This function will only check of a file exists — which means an access to the disk (which might take a little time, but not that much either)
Considering your application is probably made of dozens (if not hundreds) of PHP files, which all have to be read for each request, I don’t think one
file_existsmakes any difference.(Well, at least, as long as your are checking for a file on a local disk — not going through any network drive or anything like that)
As a sidenote : if you want to identify where CPU is spend in your PHP scripts, you might be interested by the Xdebug extension, which provides a profiling functionnality.
You can read this answer I gave some time ago, which is quite long : How can I measure the speed of code written in php? — I won’t copy-paste it here.
You might also want to read my answer to that question (there is a section where I wrote about Xdebug and profiling) : Optimizing Kohana-based Websites for Speed and Scalability