Last active
August 29, 2015 14:21
-
-
Save relaxnow/54229d556b63199c7655 to your computer and use it in GitHub Desktop.
XPath v.s. JSON on edugain metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/opt/local/bin/php53-bin/php /tmp/json_decode.php | |
count: 1090 | |
peak memory usage: 6 MiB | |
time: 13.12ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start = microtime(true); | |
$data = json_decode(file_get_contents("/var/cache/openconext/stoker/edugain/metadata.index.json")); | |
$idps = array(); | |
foreach ($data->entities as $entityId => $entity) { | |
if (in_array('idp', $entity->types)) { | |
$idps[] = $entity; | |
} | |
} | |
echo "count: " . count($idps) . PHP_EOL; | |
echo "peak memory usage: ". round(memory_get_peak_usage(true)/1024/1024, 2) . " MiB" . PHP_EOL; | |
echo "time: " . round((microtime(true) - $start) * 1000, 2) . "ms" . PHP_EOL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/opt/local/bin/php53-bin/php /tmp/xpath.php | |
count: 1090 | |
peak memory usage: 1.25 MiB | |
time: 263.38ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start = microtime(true); | |
$doc = new DomDocument(); | |
$doc->load("/var/cache/openconext/stoker/edugain/saml2-metadata.xml"); | |
$xpath = new DOMXpath($doc); | |
echo "count: " . $xpath->query("//*[local-name()='IDPSSODescriptor']/..")->length . PHP_EOL; | |
echo "peak memory usage: " . round(memory_get_peak_usage(true)/1024/1024, 2) . " MiB" . PHP_EOL; | |
echo "time: " . round((microtime(true) - $start) * 1000, 2) . "ms" . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment