Configuration files vs Database. Design suggestion

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

arborint wrote:First let me specifically address this comment. You need to remember that "just including a php file" is often slower than reading in a data file and parsing it. PHP's include parses the file as well.
Actually it isn't. Parsing an ini file is still slower than loading a PHP file. It's never OFTEN slower to load a PHP file but it is going to always be slower to parse an ini file. It may SEEM faster but in real world stress tests parsing is always slower than just loading a php file that has just variable in it.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

AKA Panama Jack wrote:Actually it isn't. Parsing an ini file is still slower than loading a PHP file. It's never OFTEN slower to load a PHP file but it is going to always be slower to parse an ini file. It may SEEM faster but in real world stress tests parsing is always slower than just loading a php file that has just variable in it.
Ok ... let me get this straight ... you are saying that is it always slower to parse an INI file than to parse a PHP file? Any size? Any kind of data? Always? Do you have benchmarks to back that up?
(#10850)
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

It depends upon what is in the ini file and what is in the PHP file.

Parsing an ini file that contains something like this...

Code: Select all

game_name = "Alien Assault Traders"
server_closed = 1
account_creation_closed = 1
tournament_setup_access = 0
player_limit = 10
will take longer than using an INCLUDE statement to load a php file that contains...

Code: Select all

<?php
$game_name = "Alien Assault Traders";
$server_closed = 1;
$account_creation_closed = 1;
$tournament_setup_access = 0;
$player_limit = 10;
?>
The code that will loop through the data from the ini file to process it into variables will take far longer than a straight include of a php file that is only variables.
Yossarian
Forum Contributor
Posts: 101
Joined: Fri Jun 30, 2006 4:43 am

I feel the need...

Post by Yossarian »

Sorry, I posted a solution that provides a quick and easy solution, not a fast one.


:cry:
Post Reply