- var_dump: documentation ( source)
- microtime: documentation ( source)
<?php
$xml = new \SimpleXMLElement('
<blog-post>
<dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
<tag xmlns:dc="http://purl.org/dc/elements/1.1/"/>
</blog-post>'
);
$t = microtime(1);
for ($i = 0; $i<100000; $i++){
count($xml->xpath('*'));
}
var_dump(microtime(1)-$t);
$t = microtime(1);
for ($i = 0; $i<100000; $i++){
$xml->count();
isset($xml->children()->tag);
$xml->children()->tag;
}
var_dump(microtime(1)-$t);