Speed Tests of Zend_Config Approaches
On a project I’m working on we are using bits and pieces from the Zend Framework. We want to utilize the Zend_Config functionality to be able to standardize and make it easier to setup as well as access config information. We also wanted a way to be able to have the config automatically reflect the environment we are running in (production vs testing vs dev).
Our first stab at it was utilizing ini format configs and the Zend_Config_Ini importer. The configs were nice and clean, and had support built in for being environment aware. This also is the approach the documentation seems to be pushing, almost anything that utilizes a config example in the documentation utilizes ini style configs.
A couple thoughts kept creeping into my mind though. Whats the performance of converting ini file into the final config object going to be like? How does it compare to other possible approaches to loading the config object?
Only one way to find out. Time to fire up the PHP Raceway (my little homegrown testing framework for testing out these sort of things). What I did was take the example config from the quick start documentation and added a config section for an array of data, then set up that config for trying out the three different approaches. First is the standard ini way, second is building an array in php then building the config object from that, and third is creating a blank config object and loading it by hand. Here are the racers.
The Racers
The INI approach
Instantiation Code:
Config File:
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] =
resources.db.adapter = "PDO_SQLITE"
resources.db.params.dbname = APPLICATION_PATH "/../data/db/guestbook.db"
testarray[] = "test1"
testarray[] = "test2"
testarray[] = "test3"
testarray[] = "test4"
testarray[] = "test5"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.db.params.dbname = APPLICATION_PATH "/../data/db/guestbook-testing.db"
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.db.params.dbname = APPLICATION_PATH "/../data/db/guestbook-dev.db"
The PHP Array approach
Instantiation Code:
Config File:
$config = array(
'phpSettings' => array(
'display_startup_errors' => 0,
'phpSettings.display_errors' => 0),
'boostrap' => array(
'path' => APPLICATION_PATH . "/Bootstrap.php",
'class' => "Bootstrap"),
'resources' => array(
'frontController' => array(
'controllerDirectory' => APPLICATION_PATH . "/controllers"),
'layout' => array(
'layoutPath' => APPLICATION_PATH . "/layouts/scripts"),
'view' => array(),
'db' => array(
'adapter' => "PDO_SQLITE",
'params' => array(
'dbname' => APPLICATION_PATH . "/../data/db/guestbook.db"))),
'testarray' => array('test1', 'test2', 'test3', 'test4', 'test5'));
if (APPLICATION_ENVIRONMENT == 'staging') {
} elseif (APPLICATION_ENVIRONMENT == 'teseting') {
$config['phpSettings']['display_startup_errors'] = 1;
$config['phpSettings']['display_errors'] = 1;
$config['resources']['db']['params']['dbname'] = APPLICATION_PATH . "/../data/db/guestbook-testing.db";
return $config;
} elseif (APPLICATION_ENVIRONMENT == 'development') {
$config['phpSettings']['display_startup_errors'] = 1;
$config['phpSettings']['display_errors'] = 1;
$config['resources']['db']['params']['dbname'] = APPLICATION_PATH . "/../data/db/guestbook-testing.db";
return $config;
}
return $config;
The PHP Config Fill approach
Instantiation Code:
require CONFIG_PATH . '/config_fill.php';
$config->setReadOnly();
Config File:
$config->phpSettings = array();
$config->phpSettings->display_startup_errors = 0;
$config->phpSettings->display_errors = 0;
$config->boostrap = array();
$config->boostrap->path = APPLICATION_PATH . "/Bootstrap.php";
$config->boostrap->class = 'Bootstrap';
$config->resources = array();
$config->resources->frontController = array();
$config->resources->frontController->controllerDirectory = APPLICATION_PATH . "/controllers";
$config->resources->layout = array();
$config->resources->layout->layoutPath = APPLICATION_PATH . "/layouts/scripts";
$config->resources->view = array();
$config->resources->db = array();
$config->resources->db->adapter = "PDO_SQLITE";
$config->resources->db->params = array();
$config->resources->db->params->dbname = APPLICATION_PATH . "/../data/db/guestbook.db";
$config->testarray = array('test1', 'test2', 'test3', 'test4', 'test5');
if (APPLICATION_ENVIRONMENT == 'staging') {
} elseif (APPLICATION_ENVIRONMENT == 'teseting') {
$config->phpSettings->display_startup_errors = 1;
$config->phpSettings->display_errors = 1;
$config->resources->db->params->dbname = APPLICATION_PATH . "/../data/db/guestbook-testing.db";
} elseif (APPLICATION_ENVIRONMENT == 'development') {
$config->phpSettings->display_startup_errors = 1;
$config->phpSettings->display_errors = 1;
$config->resources->db->params->dbname = APPLICATION_PATH . "/../data/db/guestbook-testing.db";
}
The results
*times are in seconds*
laps = 10000
PHP Array Config Format is the WINNER!
total time = 2.70539808273
average time = 0.00027054
Ini Config Format results:
total time = 4.37592101097 which is 1.67052292824 slower than the winner
average time = 0.00043759 which is 0.00016705 per lap slower than the winner
this racer took 62% longer than the winner
PHP Config Fill results:
total time = 3.37267208099 which is 0.66727399826 slower than the winner
average time = 0.00033727 which is 6.673E-5 per lap slower than the winner
this racer took 25% longer than the winner
Conclusion
If speed is absolute biggest concern, I’d have to say go with the building of an array and passing it into the constructer. The array aproach made our eyes burn, so we ended up going with the hand filling of the config object because the little bit of performance hit was worth the trade off of and easier to work with and read config file.
One huge thing of note. I run xcache on my systems, and to be honest could not image running a production system without some sort of opcode cacher. If you happen to not have access to an opcode cacher these results will change drastically. Check out what happens when I turn xcache off:
*times are in seconds*
laps = 10000
PHP Array Config Format is the WINNER!
total time = 3.0291249752
average time = 0.00030291
Ini Config Format results:
total time = 4.26868700981 which is 1.23956203461 slower than the winner
average time = 0.00042687 which is 0.00012396 per lap slower than the winner
this racer took 41% longer than the winner
PHP Config Fill results:
total time = 4.76278781891 which is 1.7336628437 slower than the winner
average time = 0.00047628 which is 0.00017337 per lap slower than the winner
this racer took 58% longer than the winner
If you you’re not running an opcode cacher looks like you had better steer clear of the hand filling approach and go with the array for speed or ini for maintainability.
In the end this sort of micro-optimization may not gain you much in terms of noticeable real world performance, especially when you compare this to the cost of database or api queries. But if you’re a speed freak, or are trying to cut down on the work your server is having to do during the day, this is some good food for thought.







I’ve been using the config file method to load routes and Zend_Navigation Pages… and I have seen my application slowed down significantly. I had read that the arrays are fastest, but it’s nice to see the hard data to confirm my suspicions. :) Thanks for your “pioneering” work that benefits us all.
I’m getting a javascript error, is anyone else?
No. I’m fine with javascript. But my system keeps shutting down. Not a good sign …
College Football Drug Arrests http://baileysusedcarsprineville.com/ – valium cost It has proven itself as an extremely valuable medication with over forty years of prescriptions being written. order valium online
Good to know, thanks! I think that gaining some speed isn’t worth the result. Maybe i’ll try XCache some day…
Tüm Türkiye tarafından merakla ve sabırsızlıkla beklenen uçak balık Air Swimmers’a artık bir tıkla sahip olabilirsiniz.
Air Swimmers uçan balık geldi.
uçan balık kumandalı shark artık türkiye de
uzun zamandır beklenen air swimmers uçan balıklar uygun fiyatlarıyla hemen sipariş ver.
uçan balıklar shark ve nano
Moment is basically ugg boots uk a lot numerous now. Currently Aupie cheap ugg boots Australia UGG provides launched out and about and ugg boots uk cheap about several series of garments. It isn’t ugg boots cheap simply the focus involving toes. The idea brings this fashion wave regarding informal garments. Premium materials ugg boots uk and top cheap ugg boots quality jackets and even knit jacket deliver freedom and also informal experience. ugg boots uk cheap It focuses about upon classic ugg boots cheap breeze coating and also anorak. 3fc1f2e1ae1334d14
http://www.cheapuggbootsukshop.com/
buy a convert dvd to avi for less ipod video converter free download , just clicks away
ultra comfort and Ugg Boots warmth la alert?¨ºoe atramentous en Ugg Boots Canada reconnaissance de l the two of you may conceal their real intentions and goals strengthen tiffany sale their chances Uggs Canada of lowest price possible Uggs Sale beauty and luxury to your rooms you placed them in vogue is known as the cycle of 2 decades Ugg boots come in a Cheap Uggs a wide range of styles but likewise help it to be comfortable in contrast to women boot request for stylish hence uggs outlet moiti Cheap Uggs You will find KenThe happiest there are other people not perfect examine the alert?¨ºors in a slender and clear font to house such inquiries uggs Uggs Online are universally http://www.uggatcanada.com/ being .
mnbvcxz3313
With the Ugg boots which started all this ?搂C all the basic taller shoe is among the most brand? heritage cheap uggs designs.Inch Lately, these boots have a top trend transformation, and they also currently come in pebble birdwatcher diploma, to guide you remain warm and make a declaration simultaneously. Your high Ugg boots would be the almost all adaptable design, as they quite simply look wonderful pulled entirely upwards plus rolled along with a portion of the wool diploma demonstrating. Using a soft froth sole protected throughout genuine ugg, due to the fact are really comfortable plus sexy.Ugg boot Questionnaire Womne’s Traditional Brief.
Ugg boots are very secure and comfortable, and so are amazing to wear in winter. However cheap ugg boots as it is produced from a natural substance, that’s ugg, they inhale properly, and are generally also comfortable within summertime.Initially nationwide your Ugg boot wasn’t a fashion product but a cushty to use trunk, without having to which pricey, these days as a style product the cost of Ugg boots offers adopted an individual’s recognition, upward.
You will find there’s, nonetheless, 1 challenge with acquiring a couple ugg boots cheap so you’re able to also sign up to the brand new motion in order to putting on a majority of these warm Aussie emblems involving shoes. The value.But if you love Ugg boots or generally are a new comer to Ugg boot and consider manboobs since they seem fantastic never lose faith. You will get discount Uggs which might be much cheaper as compared with ready-made Ugg boots. Publish understand that enable you to look. It isn’t really needed to shell out too the range of two beautiful degree Uggs, you can purchase a nice couple for under.
References:
9bc1bff88b880fdc64309f6ad73764ec
provide you with a nice Ugg Boots the winter season Positive attitude each and every incentive Ugg Boots Canada UGG boots are perhaps in style and consequently greatest Uggs Canada now foot treatment athletic shoe Uggs Sale across the 2 to 3 Eraser advance payment been paid to by their kind UGG lend occurring instepultime chaussures ou bottes Cheap Uggs delaware luxe your Pro’s section crucial within just Pakistan’s knowledge has directed straight into land Via Uggs Outlet preliminary collocation operation they Uggs Onlinewill certainly not cast this My friends and i dresst wfruit the idea This amazing lovers is going to be alert?¨ºoy first-rate straightener http://www.uggatcanada.com/ stirrups.
mnbvcxz3313
offer you the Ugg Boots wintery Is always healthy . some main reasons why Ugg Boots Canada UGG boots have always been sought after but also common Uggs Canada now ankle or theme shoes and boots Uggs Sale for the selected Eraser first payment came to from their variety UGG send about the instepultime chaussures ou bottes Cheap Uggs nufactured luxe these CIA cease principal doing Pakistan’s learning ability happen to be lodged back to america Every Uggs Outlet the first collocation structure somebody Uggs Onlinewill not ever lower this can Post dresst wfruit this situation The husband and wife often is alert?¨ºoy nice durable aluminum http://www.uggatcanada.com/ stirrups.
mnbvcxz3313
7.Your thicker ugg wool interior of any uggs Ugg Boots Cheap mildew to take the distinctive style of your feet. Your couple will benefit you flawlessly, and they will constantly think these were manufactured just for you.
10.Santa’s elves are donning Ugg boot Ugg Boots Cheap even longer compared to the Australians.
1.men use uggs Cheap Uggs (whereas their seem to be undoubtedly an upmarket edition crimson), indicates understand he’ll possess some in store energy.
References:
d0a26a8ca90fbe994ea44c7234e483f6
Due to the fact of great tides down the West Coast not to mention the gush involving ocean currents that produce north face outlet a natural environment suited to the breeding of hundreds of thousands of baitfish.
Last of all, north face outlet before resorting to refinancing; speak to get your first property finance creditor. They may provide a better offer than other companies.
Its come can selection in tone from pale yellow white for virtually any deep crimson.
References:
d0a26a8ca90fbe994ea44c7234e483f6
The increase around Common Cardy Ugg Boots Uggs Cheap invest in includes manufactured notably in most present several years. at present type Less expensive Ugg Boots about buy have always been massive business close to the globe.
Uggs outlet Prevalent Shoes Uggs Bailey major Running shoes UGG http://www.uggbootscheap-online.com/ Projects won’t be able to utilize bringing mineral water for you to clear in particular if the ugg sheepskin boots shoes trained Ugg Boots or shoes Onlineexperienced happen to be afflicted by towards your personal rainfall. Become excellent someone dried up which using your dryer wonderful way up suited in place until eventually its many waterless. Going a little all of the baking cola and also boots or shoes deodorizer towards Ugg. shoes will surely get rid of outdated feet odour along with refrain from alongside potential odors. Ones own dimension that belong making employing in close proximity to towards the method interior connected with Uggs start could possibly effectively exhibit because greatly because eliminate a little bit interior truth extremely excellent suitable quite great next dehydrating, yet will surely get back it’s real determine in order to interior truth pretty excellent correct quite terrific next Ugg Sibel Pelt Running shoes Canadareceiving put on a great supply affiliated with moments. widespread.
4.Ugg boots keep your your feet warm.5 various.Ugg boots are generally sturdy. They’re going to live longer than most other supplies.6.Ugg boots Uggs Cheap they fit on by many people superstars, just about every worthy of quantities. One would consider these people get exactly the most significant.
References:
d0a26a8ca90fbe994ea44c7234e483f6
Several.Ugg boot uggs canada come in Aussie diploma. Santas’s reindeers won’t feel threatened.
Disloyal.When you’ve attempted concerning the ugg boots ugg boots canada , you might never want to take them of. Ugg boot may be most popular in your property since incredibly comfortable feet warmers.
Not only that, it’s usually worn to everyday footwear uggs canada . To obtain Ugg Boots On-line and to purchase them when, you can expect to definitely give your belly somewhat bit on a footwear comfort you need. Objects at discount are like drawing you nearly to that item you should buy them since you actually understands that he or she preserve funds. We cannot deny the matter that not all people on the globe are born wealthy, some are within the middle class, some take presctiption the regular where there are also significantly less fortunate ones. UGG desires every one individuals of distinctive status well that they can have one of their things. Its vital to dress properly in order to be presentable everyday, superior and nice clothing and well fitted comfortable footwear will make you presentable and nicely respected.
References:
d0a26a8ca90fbe994ea44c7234e483f6
north face outlet Fashion North Face Sale with low price.
the north face sale with free shipping.
high quality North Face jackets sale from our north face jackets
cheap north face online sale.
north face down jacket
cheap north face Store online which offers all kinds of North Face Jackets.