Krinkle has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/349121 )
Change subject: benchmarks: Minor clean up
......................................................................
benchmarks: Minor clean up
Change-Id: I446ae1a9d9cdb6b26a6bb62367a432cea082f343
---
M maintenance/benchmarks/Benchmarker.php
M maintenance/benchmarks/bench_HTTP_HTTPS.php
M maintenance/benchmarks/bench_Wikimedia_base_convert.php
M maintenance/benchmarks/bench_delete_truncate.php
M maintenance/benchmarks/bench_if_switch.php
M maintenance/benchmarks/bench_strtr_str_replace.php
M maintenance/benchmarks/bench_utf8_title_check.php
M maintenance/benchmarks/bench_wfIsWindows.php
8 files changed, 30 insertions(+), 30 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/21/349121/1
diff --git a/maintenance/benchmarks/Benchmarker.php
b/maintenance/benchmarks/Benchmarker.php
index 5fab082..70dc1f4 100644
--- a/maintenance/benchmarks/Benchmarker.php
+++ b/maintenance/benchmarks/Benchmarker.php
@@ -38,7 +38,7 @@
public function __construct() {
parent::__construct();
- $this->addOption( 'count', "How many times to run a benchmark",
false, true );
+ $this->addOption( 'count', 'How many times to run a benchmark',
false, true );
}
public function bench( array $benchs ) {
@@ -68,7 +68,7 @@
'function' => $bench['function'],
'arguments' => $bench['args'],
'count' => $count,
- 'delta' => $delta,
+ 'total' => $delta,
'average' => $delta / $count,
];
}
@@ -89,9 +89,9 @@
$res['function'],
implode( ', ', $res['arguments'] )
);
- $ret .= sprintf( " %6.2fms (%6.2fms each)\n",
- $res['delta'] * 1000,
- $res['average'] * 1000
+ $ret .= sprintf( " %6.2fms (%6.4fms each)\n",
+ $res['total'] * 1e3,
+ $res['average'] * 1e3
);
}
diff --git a/maintenance/benchmarks/bench_HTTP_HTTPS.php
b/maintenance/benchmarks/bench_HTTP_HTTPS.php
index 5b64bee..1be50bd 100644
--- a/maintenance/benchmarks/bench_HTTP_HTTPS.php
+++ b/maintenance/benchmarks/bench_HTTP_HTTPS.php
@@ -42,20 +42,20 @@
[ 'function' => [ $this, 'getHTTP' ] ],
[ 'function' => [ $this, 'getHTTPS' ] ],
] );
- print $this->getFormattedResults();
+ $this->output( $this->getFormattedResults() );
}
- static function doRequest( $proto ) {
+ private function doRequest( $proto ) {
Http::get( "$proto://localhost/", [], __METHOD__ );
}
// bench function 1
- function getHTTP() {
+ protected function getHTTP() {
$this->doRequest( 'http' );
}
// bench function 2
- function getHTTPS() {
+ protected function getHTTPS() {
$this->doRequest( 'https' );
}
}
diff --git a/maintenance/benchmarks/bench_Wikimedia_base_convert.php
b/maintenance/benchmarks/bench_Wikimedia_base_convert.php
index c8a9055..bc83a24 100644
--- a/maintenance/benchmarks/bench_Wikimedia_base_convert.php
+++ b/maintenance/benchmarks/bench_Wikimedia_base_convert.php
@@ -65,8 +65,8 @@
}
protected static function makeRandomNumber( $base, $length ) {
- $baseChars = "0123456789abcdefghijklmnopqrstuvwxyz";
- $res = "";
+ $baseChars = '0123456789abcdefghijklmnopqrstuvwxyz';
+ $res = '';
for ( $i = 0; $i < $length; $i++ ) {
$res .= $baseChars[mt_rand( 0, $base - 1 )];
}
diff --git a/maintenance/benchmarks/bench_delete_truncate.php
b/maintenance/benchmarks/bench_delete_truncate.php
index 2369d99..042f8bd 100644
--- a/maintenance/benchmarks/bench_delete_truncate.php
+++ b/maintenance/benchmarks/bench_delete_truncate.php
@@ -102,5 +102,5 @@
}
}
-$maintClass = "BenchmarkDeleteTruncate";
+$maintClass = 'BenchmarkDeleteTruncate';
require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/maintenance/benchmarks/bench_if_switch.php
b/maintenance/benchmarks/bench_if_switch.php
index 46c9d39..32c3932 100644
--- a/maintenance/benchmarks/bench_if_switch.php
+++ b/maintenance/benchmarks/bench_if_switch.php
@@ -42,11 +42,11 @@
[ 'function' => [ $this, 'doElseIf' ] ],
[ 'function' => [ $this, 'doSwitch' ] ],
] );
- print $this->getFormattedResults();
+ $this->output( $this->getFormattedResults() );
}
// bench function 1
- function doElseIf() {
+ protected function doElseIf() {
$a = 'z';
if ( $a == 'a' ) {
} elseif ( $a == 'b' ) {
@@ -69,7 +69,7 @@
}
// bench function 2
- function doSwitch() {
+ protected function doSwitch() {
$a = 'z';
switch ( $a ) {
case 'b':
diff --git a/maintenance/benchmarks/bench_strtr_str_replace.php
b/maintenance/benchmarks/bench_strtr_str_replace.php
index 156f8fc..276e666 100644
--- a/maintenance/benchmarks/bench_strtr_str_replace.php
+++ b/maintenance/benchmarks/bench_strtr_str_replace.php
@@ -51,22 +51,22 @@
[ 'function' => [ $this, 'benchstrtr_indirect' ] ],
[ 'function' => [ $this, 'benchstr_replace_indirect' ]
],
] );
- print $this->getFormattedResults();
+ $this->output( $this->getFormattedResults() );
}
- function benchstrtr() {
+ protected function benchstrtr() {
strtr( "[[MediaWiki:Some_random_test_page]]", "_", " " );
}
- function benchstr_replace() {
+ protected function benchstr_replace() {
str_replace( "_", " ", "[[MediaWiki:Some_random_test_page]]" );
}
- function benchstrtr_indirect() {
+ protected function benchstrtr_indirect() {
bfNormalizeTitleStrTr( "[[MediaWiki:Some_random_test_page]]" );
}
- function benchstr_replace_indirect() {
+ protected function benchstr_replace_indirect() {
bfNormalizeTitleStrReplace(
"[[MediaWiki:Some_random_test_page]]" );
}
}
diff --git a/maintenance/benchmarks/bench_utf8_title_check.php
b/maintenance/benchmarks/bench_utf8_title_check.php
index b2f7e96..9ba1623 100644
--- a/maintenance/benchmarks/bench_utf8_title_check.php
+++ b/maintenance/benchmarks/bench_utf8_title_check.php
@@ -32,6 +32,8 @@
class BenchUtf8TitleCheck extends Benchmarker {
private $data;
+ private $isutf8;
+
public function __construct() {
parent::__construct();
@@ -84,29 +86,27 @@
];
}
$this->bench( $benchmarks );
- print $this->getFormattedResults();
+ $this->output( $this->getFormattedResults() );
}
- private $isutf8;
-
- function use_regexp( $s ) {
+ protected function use_regexp( $s ) {
$this->isutf8 = preg_match(
'/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
'[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
}
- function use_regexp_non_capturing( $s ) {
+ protected function use_regexp_non_capturing( $s ) {
// Same as above with a non-capturing subgroup.
$this->isutf8 = preg_match(
'/^(?:[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
'[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
}
- function use_regexp_once_only( $s ) {
+ protected function use_regexp_once_only( $s ) {
// Same as above with a once-only subgroup.
$this->isutf8 = preg_match(
'/^(?>[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
'[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
}
- function use_mb_check_encoding( $s ) {
+ protected function use_mb_check_encoding( $s ) {
$this->isutf8 = mb_check_encoding( $s, 'UTF-8' );
}
}
diff --git a/maintenance/benchmarks/bench_wfIsWindows.php
b/maintenance/benchmarks/bench_wfIsWindows.php
index ac0caf6..f26dbb2 100644
--- a/maintenance/benchmarks/bench_wfIsWindows.php
+++ b/maintenance/benchmarks/bench_wfIsWindows.php
@@ -45,17 +45,17 @@
print $this->getFormattedResults();
}
- static function is_win() {
+ protected static function is_win() {
return substr( php_uname(), 0, 7 ) == 'Windows';
}
// bench function 1
- function wfIsWindows() {
+ protected function wfIsWindows() {
return self::is_win();
}
// bench function 2
- function wfIsWindowsCached() {
+ protected function wfIsWindowsCached() {
static $isWindows = null;
if ( $isWindows == null ) {
$isWindows = self::is_win();
--
To view, visit https://gerrit.wikimedia.org/r/349121
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I446ae1a9d9cdb6b26a6bb62367a432cea082f343
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits