Welcome Guest, Not a member yet? Register   Sign In
HMVC vs MVC speed comparison ... any ?
#1

[eluser]ckissi[/eluser]
Hello,

Anybody tested/compared performance/speed for both ?

If you go to MY_Router.php (for HMVC) you can see tons of is_dir and is_file function calls in "locate" function. I really wonder how it affects speed as it makes tons of tests before files are included and executed.

Code:
foreach (Modules::$locations as $location => $offset) {
        
            /* module exists? */
            if (is_dir($source = $location.$module.'/controllers/')) {
                
                $this->module = $module;
                $this->directory = $offset.$module.'/controllers/';
                
                /* module sub-controller exists? */
                if($directory AND is_file($source.$directory.$ext)) {
                    return array_slice($segments, 1);
                }
                    
                /* module sub-directory exists? */
                if($directory AND is_dir($module_subdir = $source.$directory.'/')) {
                            
                    $this->directory .= $directory.'/';

                    /* module sub-directory controller exists? */
                    if(is_file($module_subdir.$directory.$ext)) {
                        return array_slice($segments, 1);
                    }
                
                    /* module sub-directory sub-controller exists? */
                    if($controller AND is_file($module_subdir.$controller.$ext))    {
                        return array_slice($segments, 2);
                    }
                }
            
                /* module controller exists? */            
                if(is_file($source.$module.$ext)) {
                    return $segments;
                }
            }
        }

We would like to go for HMVC but it's mission critical application when it comes to speed and currently there seems to be a big disadvantage because of these file/dir test functions.
#2

[eluser]tonanbarbarian[/eluser]
i have not tested this, but you can get some idea by writing your own test script
in particular you are looking for the difference in speed if is_file and is_dir finds files and directories as to when they do not.

so write a script that loops 1000 times or more and have it do nothing
put code before and after the loop to record the time so you can determine the duration
you can even put code inside the loop to determine the time of each iteration and then average those times if you want
but after you run that script a few times you will get an idea of how long the script will take to run when doing nothing

then add code inside the loop and have the code do is_file and is_dir for files and directories you know exists
run the script again a few times and get a feel for how much time it takes

then modify the code so the is_file and is_dir point to files and directories that do not exist
run the script again a few times and see what times you get

from that you should be able to get a "feel" for the amount of time is required by a successfull and unsuccessful is_file and is_directory call

that should then give you some idea as to if the is_file and is_dir calls in HMVC will slow the site significantly or not.

my gut instinct tells me it is probably fractionally slower to check for a file or dir that does not exist, but i am not sure

also it is worth determining if the is_file and is_dir calls in the code you are worried about are absolute or relative.
I suspect relative paths are slower because it will have to see if the file or directory exists in multiple locations based on the paths that php knows about.

i would be interested in knowing what figures you get and whether you determine if the calls slow things down or not
#3

[eluser]WanWizard[/eluser]
PHP caches stat calls, so I don't expect much delay.




Theme © iAndrew 2016 - Forum software by © MyBB