MediaWiki  master
bench_HTTP_HTTPS.php
Go to the documentation of this file.
1 <?php
28 
29 require_once __DIR__ . '/../includes/Benchmarker.php';
30 
36 class BenchHttpHttps extends Benchmarker {
37  public function __construct() {
38  parent::__construct();
39  $this->addDescription( 'Benchmark HTTP request vs HTTPS request.' );
40  }
41 
42  public function execute() {
43  $this->bench( [
44  [ 'function' => [ $this, 'getHTTP' ] ],
45  [ 'function' => [ $this, 'getHTTPS' ] ],
46  ] );
47  }
48 
49  private function doRequest( $proto ) {
50  MediaWikiServices::getInstance()->getHttpRequestFactory()->
51  get( "$proto://localhost/", [], __METHOD__ );
52  }
53 
57  protected function getHTTP() {
58  $this->doRequest( 'http' );
59  }
60 
64  protected function getHTTPS() {
65  $this->doRequest( 'https' );
66  }
67 }
68 
69 $maintClass = BenchHttpHttps::class;
70 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:38
$maintClass
$maintClass
Definition: bench_HTTP_HTTPS.php:69
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:146
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:323
BenchHttpHttps\getHTTP
getHTTP()
bench function 1
Definition: bench_HTTP_HTTPS.php:57
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:51
BenchHttpHttps\doRequest
doRequest( $proto)
Definition: bench_HTTP_HTTPS.php:49
BenchHttpHttps\execute
execute()
Do the actual work.
Definition: bench_HTTP_HTTPS.php:42
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:41
BenchHttpHttps
Maintenance script that benchmarks HTTP request vs HTTPS request.
Definition: bench_HTTP_HTTPS.php:36
BenchHttpHttps\__construct
__construct()
Default constructor.
Definition: bench_HTTP_HTTPS.php:37
BenchHttpHttps\getHTTPS
getHTTPS()
bench function 2
Definition: bench_HTTP_HTTPS.php:64