summaryrefslogtreecommitdiff
path: root/plugins/af_readability/vendor/masterminds/html5/test/benchmark/run.php
blob: 2ca1907830aa8e85d3ab18eeca2d620a7b1fb11e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);