Liquid Fire Posted July 30, 2008 Share Posted July 30, 2008 This question is really no t about the speed of code and in seconds but the speed of code as in percent increased. I am building my base model class of my MVC framework and i am testing it with a model that has 2 field(id, and title). Now i do a loop that create this model 5000 times and what happens is that the constructor set a multi dimension array like this: $this->fields_structure = array ( 'id' => array ( 'field' => 'stt.id', 'field_type' => 'int', 'key_type' => 'primary', 'save_type' => 'insert' ), 'title' => array ( 'field' => 'stt.title', 'field_type' => 'string', 'save_type' => 'both' ) ); and it take from 0.17 -> 0.24 seconds. Now there is in total 20 options that can be set and when i add the function sets all the default value for these option the run time is from 0.46 -> 0.53. And what the function that sets the defaults does is loop through the $this->fields_structure and to a array_merge($defaults, $this->fields_structure[$key]) and then does a set of loops for the last 3 three options that are based on previous options. does that seem like a normal percentage increase in speed. Is there a better way to store option for model fields besides having an array? Link to comment https://forums.phpfreaks.com/topic/117393-code-speed-question/ Share on other sites More sharing options...
unkwntech Posted July 30, 2008 Share Posted July 30, 2008 There are to many variables involved to give a normal range. Everything on the 'server' effects the exicution time. Link to comment https://forums.phpfreaks.com/topic/117393-code-speed-question/#findComment-603856 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.