Liquid Fire Posted September 2, 2008 Share Posted September 2, 2008 I am in the process of rebuild my ORM(or model) portion of my framework as my first version was very bulky and hard to maintain(even tho my out of the box, no extra configuration testing showed it was 2X faster then doctrine). Now i am not sure which way is better or faster so let me ask here. Basically i stored a static member that stores the configuration options for each field being pulled like: <?php self::$fields = array ( 'field1' => array ( 'config1' => 'value1', 'config2' => 'value2' //etc... ), 'field2' => array ( 'config1' => 'value1', 'config2' => 'value2' //etc... ) etc... ); ?> Right now there are a total of 9 possible configuration values(an by the end their might be a few more) and all but 2 have default values and don't need to be manually set. Now i have 2 options and not sure which one will effect performance more, but i have an idea. The 2 options are: 1. Make sure each configuration is set(required large file size but no code to check if a configuration is set so warning don't show). This way i just set every configuration option for every field and that way i don't need !empty() or isset() code so that warning don't show up. the thing is it could really up the file size where if the you only need on average 4 configuration but you always have all 11 and you have like 50 fields, that is a lot of extra code to parse. 2. Only put the configures you need and leave the rest out(smaller file sizes but code to make sure things are set to not throw warnings). This will make the base model file smaller but i will need to add code to check to make sure configurations are set so no warning show up. Now i am assuming that loading/parsing a large file is faster than doing check for configurations every time but maybe that is not the way i should go. What do you think? SIDE NOTE: The files i am taking about are automatically generated through a xml configuration file so tme to code the file is not a issue. Quote Link to comment https://forums.phpfreaks.com/topic/122449-always-include-options-or-check-for-them/ Share on other sites More sharing options...
Liquid Fire Posted September 4, 2008 Author Share Posted September 4, 2008 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/122449-always-include-options-or-check-for-them/#findComment-633299 Share on other sites More sharing options...
keeB Posted September 4, 2008 Share Posted September 4, 2008 Marking this one so I remember to check it. Reason I am not answering now is because the question isn't readily apparent. Quote Link to comment https://forums.phpfreaks.com/topic/122449-always-include-options-or-check-for-them/#findComment-633326 Share on other sites More sharing options...
448191 Posted September 4, 2008 Share Posted September 4, 2008 I think the difference will be negligible. There's a third option btw: assign default values to optional indexes, then merge with given values. A lot less messy IMO. If you really want to know, bench. It makes no sense asking us, when you could just test for it. Quote Link to comment https://forums.phpfreaks.com/topic/122449-always-include-options-or-check-for-them/#findComment-633432 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.