MediaWiki  1.34.0
bench_HTTP_HTTPS.php
Go to the documentation of this file.
1 <?php
28 
29 require_once __DIR__ . '/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 
54  // bench function 1
55  protected function getHTTP() {
56  $this->doRequest( 'http' );
57  }
58 
59  // bench function 2
60  protected function getHTTPS() {
61  $this->doRequest( 'https' );
62  }
63 }
64 
65 $maintClass = BenchHttpHttps::class;
66 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
$maintClass
$maintClass
Definition: bench_HTTP_HTTPS.php:65
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:348
BenchHttpHttps\getHTTP
getHTTP()
Definition: bench_HTTP_HTTPS.php:55
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:50
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:40
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()
Definition: bench_HTTP_HTTPS.php:60