Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
BenchLookup | n/a |
0 / 0 |
n/a |
0 / 0 |
3 | n/a |
0 / 0 |
|||
__construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
execute | n/a |
0 / 0 |
n/a |
0 / 0 |
2 |
1 | <?php |
2 | /** |
3 | * Copyright (C) 2018 Kunal Mehta <legoktm@debian.org> |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 3 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | namespace MediaWiki\SecureLinkFixer; |
20 | |
21 | use Benchmarker; |
22 | use MediaWiki\MediaWikiServices; |
23 | use const RUN_MAINTENANCE_IF_MAIN; |
24 | |
25 | $IP = getenv( 'MW_INSTALL_PATH' ); |
26 | if ( $IP === false ) { |
27 | $IP = __DIR__ . '/../../..'; |
28 | } |
29 | require_once "$IP/maintenance/includes/Benchmarker.php"; |
30 | |
31 | /** |
32 | * Benchmark the current HSTSPreloadLookup implementation |
33 | * |
34 | * @codeCoverageIgnore |
35 | */ |
36 | class BenchLookup extends Benchmarker { |
37 | public function __construct() { |
38 | parent::__construct(); |
39 | $this->addDescription( 'Benchmark for HSTSPreloadLookup' ); |
40 | $this->requireExtension( 'SecureLinkFixer' ); |
41 | } |
42 | |
43 | public function execute() { |
44 | $lookup = MediaWikiServices::getInstance()->getService( 'HSTSPreloadLookup' ); |
45 | $domains = [ |
46 | // Need to traverse up one domain to find it |
47 | 'foobar.dev', |
48 | // Directly in map |
49 | 'wikipedia.org', |
50 | // Need to traverse up one domain to not find it |
51 | 'not-preloaded.com', |
52 | // Need to traverse up 6 domains to not find it |
53 | 'pathological.case.that.is.not.preloaded.org', |
54 | ]; |
55 | $benches = []; |
56 | foreach ( $domains as $domain ) { |
57 | $benches[] = [ |
58 | 'function' => [ $lookup, 'isPreloaded' ], |
59 | 'args' => [ $domain ], |
60 | ]; |
61 | } |
62 | $this->bench( $benches ); |
63 | } |
64 | } |
65 | |
66 | $maintClass = BenchLookup::class; |
67 | require_once RUN_MAINTENANCE_IF_MAIN; |