Liquid Fire Posted February 23, 2008 Share Posted February 23, 2008 I have built a framework and right now am trying to find any type of speed issue/bottleneck and think i found my big one. I have a recursive directory search function <?php function check_for_file($directory, $file_name) { //get the directory handle $directory_handle = opendir($directory); while($resource = readdir($directory_handle)) { //make sure it is not a dotted directory if(!is_dot($resource)) { if(is_dir($directory . '/' . $resource)) { //we need to call ourself if this is a directory $search_result = check_for_file($directory . '/' . $resource, $file_name); if($search_result !== false ) { return $search_result; } } else { //let check to see if this is the file if(file_exists($directory . '/' . $file_name)) { return $directory . '/' . $file_name; } } } } return false; } ?> now in there are 6 folders and about 35-40 files to search and out of the total .56 second it takes to load the data from my framework, .40 is taken up inside this function. does anyone see where i can optimise my code? Quote Link to comment Share on other sites More sharing options...
Liquid Fire Posted February 23, 2008 Author Share Posted February 23, 2008 why can't i edit my post? anyways, also if there is a better way to do the auto load where i don't have to worry about put every directory in class file paths and still allows me to organize my files into a clean directory structure. Quote Link to comment Share on other sites More sharing options...
Liquid Fire Posted February 23, 2008 Author Share Posted February 23, 2008 anyone? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.