Created
February 3, 2024 00:56
-
-
Save beberlei/be346b3e1139d3b70f74b290cd361a13 to your computer and use it in GitHub Desktop.
This file contains 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 | |
use Tideways\Profiler\WithSpan; | |
$dom = new DOMDocument(); | |
$root = $dom->createElementNS('http://www.w3.org/2000/xhtml', 'html'); | |
$dom->appendChild($root); | |
#[WithSpan] | |
function addParagraphs($dom, $node, $number) { | |
$s = microtime(true); | |
for ($i = 0; $i < $number; $i++) { | |
$element = $dom->createElementNS('http://www.w3.org/2000/xhtml', 'p', 'Hello World'); | |
$node->appendChild($element); | |
} | |
echo number_format(microtime(true) - $s, 6) . "\n"; | |
} | |
for ($i = 0; $i < 3; $i++) { | |
addParagraphs($dom, $root, 10000); | |
usleep(PHP_VERSION_ID >= 80300 ? 1000 : 10000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment