wiki.techinc.nl/maintenance/benchmarks/bench_HTTP_HTTPS.php
Aryeh Gregor 9018579681 Deprecate the Http class
All methods got moved to HttpRequestFactory or MWHttpRequest or dropped.

I made the return value of the new HttpRequestFactory::request/get/post
methods null on error instead of false, so that when we drop PHP 7
support, we can use a "?string" return value. This could theoretically
change behavior of code that was switched from the old Http methods, but
probably won't. I kept the old behavior for the deprecated methods.

I changed the default value of $wgHTTPProxy from false to ''. This way
it should be usable directly without a trivial wrapper method. For the
benefit of anyone who might have set it to false in LocalSettings.php, I
also recommend casting to string just in case.

Http::$httpEngine is deprecated. Eventually it will be removed along
with the curl and PHP engines, leaving only the Guzlle engine.

I also added deprecation of MWHttpRequest::factory, which occurred in
1.31, to the release notes for 1.34. Now hopefully we can hard-deprecate
it in another couple of versions.

Bug: T214390
Change-Id: I2a316a758d793857f248bd251b90f5e9a6440e3a
2019-05-06 12:07:26 +03:00

66 lines
1.8 KiB
PHP

<?php
/**
* Benchmark HTTP request vs HTTPS request.
*
* This come from r75429 message.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup Benchmark
* @author Platonides
*/
use MediaWiki\MediaWikiServices;
require_once __DIR__ . '/Benchmarker.php';
/**
* Maintenance script that benchmarks HTTP request vs HTTPS request.
*
* @ingroup Benchmark
*/
class BenchHttpHttps extends Benchmarker {
public function __construct() {
parent::__construct();
$this->addDescription( 'Benchmark HTTP request vs HTTPS request.' );
}
public function execute() {
$this->bench( [
[ 'function' => [ $this, 'getHTTP' ] ],
[ 'function' => [ $this, 'getHTTPS' ] ],
] );
}
private function doRequest( $proto ) {
MediaWikiServices::getInstance()->getHttpRequestFactory()->
get( "$proto://localhost/", [], __METHOD__ );
}
// bench function 1
protected function getHTTP() {
$this->doRequest( 'http' );
}
// bench function 2
protected function getHTTPS() {
$this->doRequest( 'https' );
}
}
$maintClass = BenchHttpHttps::class;
require_once RUN_MAINTENANCE_IF_MAIN;