Re: [Config] Extremely slow

From: Date: Tue, 25 Nov 2003 07:56:43 +0000
Subject: Re: [Config] Extremely slow
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9124@lists.php.net to get a copy of this message
<ts@siteartwork.de> wrote : > I have a XML-File with let's say 700 lines of data. When reading this > configuration it takes a bunch of time till the operation is finished. > However, I'm able to use a cache-mechanism: once in a while the XML-File > will be written as a PHP-Array into another file, from which the > configuration will then be read. > > Anyway, this is not quite the solution I'm looking for: Has annyone > suggestions where I should look for a bottleneck in my system-configuration > so reading the xml-file will get faster? > > Here's my code: > > $oConfig = new Config; > $this->oConfigRoot = &$oConfig->parseConfig($sPathToSettingFile, 'XML'); > $aOpenedFiles[$sMD5Hash] = &$this->oConfigRoot; > // var_dump($this->oConfigRoot); > > > Btw.: When un-commenting the "var_dump()" statement, I get a "Nesting level > too deep"-Fatal-Error... Parsing XML is slow in PHP. Furthermore, the Config package is slow and therefore should be used only to manipulate configuration files, not to read them. If you want a fast solution you can try to wait for PHP 5 and its SimpleXML parser or have your configuration file be converted by Config to a PHP array and then access this array directly in PHP (a lot faster). Level too deep is because there is a lot of recursion in Config. You cannot use var_dump() with Config. Try to use the toArray() method instead. HTH Bertrand

« previous php.pear.general (#9124) next »