For those who come to this question because they want to know if there are any performance differences between using an INI file that needs to be parsed and a PHP file that is just included (and can be cached by PHP): Yes, there are differences, but they are so small that it does not really matter.
My test case is a config.ini file with 20 key / value pairs and a config.php with the same 20 key / value pairs written as it defines. The PHP version is 5.4.9 on Ubuntu Linux 13.04.
key1 = value1 ... key20 = value20
against.
<?php define("key1", "value1"); ... define("key2", "value20");
Two test cases, including configs:
<?php $CONF = parse_ini_file("config.ini");
against.
<?php require_once "config.php";
I tested performance with ab -c 25 -n 10000 .
Result without PHP cache:
ini: Requests per second: 2660.89 [#/sec] (mean) php: Requests per second: 2642.28 [#/sec] (mean)
Result with PHP APC cache:
ini: Requests per second: 3294.47 [#/sec] (mean) php: Requests per second: 3307.89 [#/sec] (mean)
I ran the tests several times, of course, the numbers will change every time, but the consensus is this: config.ini little faster when the PHP cache is not used, config.php little faster when the PHP cache is used. But the difference is so small that the solution should not be based on performance.
kayahr May 17 '13 at 7:11 2013-05-17 07:11
source share