i have a problem using XMLParser and simplexml_load_dom. Im trying to search in 4 with 2MB each files and in a 27 MB file. The problem is not with the memory but with the execution time (around 50s). How can i optimize the code?
public function searchInFeed()
{
$feed =& $this->getModel('feed','afiliereFeeduriModel');
$myfeeds = $feed->selectFeed();
foreach ($myfeeds as $f)
{
$x = new XMLReader();
$x->open($f->url);
$z = microtime(true);
$doc = new DOMDocument('1.0', 'UTF-8');
set_time_limit(0);
while ($x->read())
{
if ($x->nodeType === XMLReader::ELEMENT)
{
$nod = simplexml_import_dom($doc->importNode($x->expand(), true));
$data['text'] = 'Chicco termometru';
$data['titlu'] = 'title';
$data['nod'] = &$nod;
if ($this->searchInXML($data))
{
echo $nod->title."<br>";
}
$x->next();
}
}
}
echo microtime(true) - $z."<br>";
echo memory_get_usage()/1024/1024;
die();
}