MediaWiki
master
Toggle main menu visibility
benchmarkJsValidate.php
Go to the documentation of this file.
1
<?php
7
8
use
MediaWiki\Maintenance\Benchmarker
;
9
10
// @codeCoverageIgnoreStart
11
require_once __DIR__ .
'/../includes/Benchmarker.php'
;
12
// @codeCoverageIgnoreEnd
13
21
class
BenchmarkJsValidate
extends
Benchmarker
{
23
protected
$defaultCount
= 10;
24
25
public
function
__construct
() {
26
parent::__construct();
27
$this->
addDescription
(
'Measure JavaScript syntax validation.'
);
28
$this->
addOption
(
'file'
,
'Path to JS file. Default: jquery'
,
false
,
true
);
29
}
30
31
public
function
execute
() {
32
$file = $this->
getOption
(
'file'
, __DIR__ .
'/data/jsmin/jquery-3.2.1.js.gz'
);
33
$content = $this->
loadFile
( $file );
34
if
( $content ===
false
) {
35
$this->
fatalError
(
'Unable to open input file'
);
36
}
37
38
$filename = basename( $file );
39
40
$this->
bench
( [
41
"Peast::parse ($filename)"
=> [
42
'function'
=>
static
function
( $content ) {
43
Peast\Peast::ES2019( $content )->parse();
44
},
45
'args'
=> [ $content ]
46
]
47
] );
48
}
49
}
50
51
// @codeCoverageIgnoreStart
52
$maintClass
= BenchmarkJsValidate::class;
53
require_once RUN_MAINTENANCE_IF_MAIN;
54
// @codeCoverageIgnoreEnd
$maintClass
$maintClass
Definition
addChangeTag.php:56
BenchmarkJsValidate
Measure ResourceLoader syntax validation for user-supplied JavaScript.
Definition
benchmarkJsValidate.php:21
BenchmarkJsValidate\$defaultCount
$defaultCount
Definition
benchmarkJsValidate.php:23
BenchmarkJsValidate\execute
execute()
Do the actual work.
Definition
benchmarkJsValidate.php:31
BenchmarkJsValidate\__construct
__construct()
Default constructor.
Definition
benchmarkJsValidate.php:25
MediaWiki\Maintenance\Benchmarker
Base class for benchmark scripts.
Definition
Benchmarker.php:29
MediaWiki\Maintenance\Benchmarker\bench
bench(array $benchs)
Definition
Benchmarker.php:39
MediaWiki\Maintenance\Benchmarker\loadFile
loadFile( $file)
Definition
Benchmarker.php:209
MediaWiki\Maintenance\Maintenance\fatalError
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Definition
Maintenance.php:545
MediaWiki\Maintenance\Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Definition
Maintenance.php:265
MediaWiki\Maintenance\Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition
Maintenance.php:299
MediaWiki\Maintenance\Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition
Maintenance.php:335
maintenance
benchmarks
benchmarkJsValidate.php
Generated on
for MediaWiki by
1.18.0