summaryrefslogtreecommitdiff
path: root/plugins/af_readability/vendor/masterminds/html5/test/benchmark/run.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-07-31 09:15:00 +0300
committerAndrew Dolgov <[email protected]>2022-07-31 09:15:00 +0300
commit7187ab859db71fd706a6ea67587b21ad0fe588df (patch)
tree0c36632720ec06fb18dd999132fffdb55284fb8c /plugins/af_readability/vendor/masterminds/html5/test/benchmark/run.php
parent4aefbd628e9a0e1eac58523904ad887b0635cda3 (diff)
fork masterminds html5-php
Diffstat (limited to 'plugins/af_readability/vendor/masterminds/html5/test/benchmark/run.php')
-rw-r--r--plugins/af_readability/vendor/masterminds/html5/test/benchmark/run.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/af_readability/vendor/masterminds/html5/test/benchmark/run.php b/plugins/af_readability/vendor/masterminds/html5/test/benchmark/run.php
new file mode 100644
index 000000000..2ca190783
--- /dev/null
+++ b/plugins/af_readability/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);