summaryrefslogtreecommitdiff
path: root/vendor/masterminds/html5/test/benchmark/run.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-12-13 20:00:46 +0300
committerAndrew Dolgov <[email protected]>2022-12-13 20:00:46 +0300
commit0226e0ca0dc70f9a0310b3eef045ee1c1e0ca3ac (patch)
tree254c0e880693c2636107308b5931951cfa501311 /vendor/masterminds/html5/test/benchmark/run.php
split into a separate repo
Diffstat (limited to 'vendor/masterminds/html5/test/benchmark/run.php')
-rw-r--r--vendor/masterminds/html5/test/benchmark/run.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/masterminds/html5/test/benchmark/run.php b/vendor/masterminds/html5/test/benchmark/run.php
new file mode 100644
index 0000000..2ca1907
--- /dev/null
+++ b/vendor/masterminds/html5/test/benchmark/run.php
@@ -0,0 +1,29 @@
+<?php
+
+require __DIR__ . '/../../vendor/autoload.php';
+
+$iterations = isset($argv[1]) ? $argv[1] : 100;
+
+$html5 = new Masterminds\HTML5();
+$content = file_get_contents(__DIR__ . '/example.html');
+$dom = $html5->loadHTML($content);
+
+$samples = array();
+for ($i = 0; $i < $iterations; ++$i) {
+ $t = microtime(true);
+ $dom = $html5->loadHTML($content);
+ $samples[] = microtime(true) - $t;
+}
+$time = array_sum($samples) / count($samples);
+echo 'Loading: ' . ($time * 1000) . "\n";
+
+$samples = array();
+for ($i = 0; $i < $iterations; ++$i) {
+ $t = microtime(true);
+ $html5->saveHTML($dom);
+ $samples[] = microtime(true) - $t;
+}
+$time = array_sum($samples) / count($samples);
+echo 'Writing: ' . ($time * 1000) . "\n";
+
+exit(0);