MediaWiki  master
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;
$maintClass
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
Maintenance script that benchmarks HTTP request vs HTTPS request.
bench(array $benchs)
Definition: Benchmarker.php:51
addDescription( $text)
Set the description text.
Base class for benchmark scripts.
Definition: Benchmarker.php:41