3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument( '1.0', 'UTF-8' ); $doc->loadHTML( '<?xml encoding="utf-8" ?><p><p><p><p><p>five<p><p><p><p><p>ten' ); $body = $doc->documentElement->childNodes[0]; $start = hrtime( true ); for ( $i = 0; $i < 1_000_000; $i++ ) $dummy = $body->childNodes->item( 4 ); $stop = hrtime( true ); $seconds = ( $stop - $start ) / 1_000_000_000; echo "$seconds s" . PHP_EOL; $start = hrtime( true ); for ( $i = 0; $i < 1_000_000; $i++ ) $dummy = $body->childNodes[4]; $stop = hrtime( true ); $seconds = ( $stop - $start ) / 1_000_000_000; echo "$seconds s" . PHP_EOL;

preferences:
28.16 ms | 404 KiB | 5 Q