diff options
Diffstat (limited to 'maintenance/benchmarks')
-rw-r--r-- | maintenance/benchmarks/Benchmarker.php | 10 | ||||
-rw-r--r-- | maintenance/benchmarks/README | 7 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_HTTP_HTTPS.php | 4 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_delete_truncate.php | 4 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_if_switch.php | 4 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_strtr_str_replace.php | 4 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_utf8_title_check.php | 6 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_wfBaseConvert.php | 4 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_wfIsWindows.php | 4 | ||||
-rw-r--r-- | maintenance/benchmarks/benchmarkHooks.php | 4 | ||||
-rw-r--r-- | maintenance/benchmarks/benchmarkPurge.php | 4 |
11 files changed, 31 insertions, 24 deletions
diff --git a/maintenance/benchmarks/Benchmarker.php b/maintenance/benchmarks/Benchmarker.php index 98b35b53..dd558f32 100644 --- a/maintenance/benchmarks/Benchmarker.php +++ b/maintenance/benchmarks/Benchmarker.php @@ -27,7 +27,7 @@ * @ingroup Benchmark */ -require_once( __DIR__ . '/../Maintenance.php' ); +require_once __DIR__ . '/../Maintenance.php'; /** * Base class for benchmark scripts. @@ -48,20 +48,20 @@ abstract class Benchmarker extends Maintenance { foreach( $benchs as $bench ) { // handle empty args - if(!array_key_exists( 'args', $bench )) { + if( !array_key_exists( 'args', $bench ) ) { $bench['args'] = array(); } $bench_number++; $start = microtime( true ); - for( $i=0; $i<$count; $i++ ) { + for( $i = 0; $i < $count; $i++ ) { call_user_func_array( $bench['function'], $bench['args'] ); } $delta = microtime( true ) - $start; // function passed as a callback if( is_array( $bench['function'] ) ) { - $ret = get_class( $bench['function'][0] ). '->' . $bench['function'][1]; + $ret = get_class( $bench['function'][0] ) . '->' . $bench['function'][1]; $bench['function'] = $ret; } @@ -85,7 +85,7 @@ abstract class Benchmarker extends Maintenance { join( ', ', $res['arguments'] ) ); $ret .= sprintf( " %6.2fms (%6.2fms each)\n", - $res['delta'] * 1000, + $res['delta'] * 1000, $res['average'] * 1000 ); } diff --git a/maintenance/benchmarks/README b/maintenance/benchmarks/README new file mode 100644 index 00000000..c021abd2 --- /dev/null +++ b/maintenance/benchmarks/README @@ -0,0 +1,7 @@ +This directory hold several benchmarking scripts used as a proof of speed +or to track PHP performances over time. + +To get somehow accurate result, you might want to bound the PHP process +to a specific CPU with `taskset` and raise its priority with `nice`. Example: + + $ taskset 1 nice -n-10 php bench_wfIsWindows.php diff --git a/maintenance/benchmarks/bench_HTTP_HTTPS.php b/maintenance/benchmarks/bench_HTTP_HTTPS.php index fa76ae22..6f800fb3 100644 --- a/maintenance/benchmarks/bench_HTTP_HTTPS.php +++ b/maintenance/benchmarks/bench_HTTP_HTTPS.php @@ -24,7 +24,7 @@ * @author Platonides */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmarks HTTP request vs HTTPS request. @@ -62,4 +62,4 @@ class bench_HTTP_HTTPS extends Benchmarker { } $maintClass = 'bench_HTTP_HTTPS'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_delete_truncate.php b/maintenance/benchmarks/bench_delete_truncate.php index d9741496..3eff534b 100644 --- a/maintenance/benchmarks/bench_delete_truncate.php +++ b/maintenance/benchmarks/bench_delete_truncate.php @@ -21,7 +21,7 @@ * @ingroup Benchmark */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmarks SQL DELETE vs SQL TRUNCATE. @@ -101,4 +101,4 @@ class BenchmarkDeleteTruncate extends Benchmarker { } $maintClass = "BenchmarkDeleteTruncate"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_if_switch.php b/maintenance/benchmarks/bench_if_switch.php index 1f590d4d..80fd9623 100644 --- a/maintenance/benchmarks/bench_if_switch.php +++ b/maintenance/benchmarks/bench_if_switch.php @@ -24,7 +24,7 @@ * @author Platonides */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmark if elseif... versus switch case. @@ -93,4 +93,4 @@ class bench_if_switch extends Benchmarker { } $maintClass = 'bench_if_switch'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_strtr_str_replace.php b/maintenance/benchmarks/bench_strtr_str_replace.php index 10c5cd0b..bd21b186 100644 --- a/maintenance/benchmarks/bench_strtr_str_replace.php +++ b/maintenance/benchmarks/bench_strtr_str_replace.php @@ -23,7 +23,7 @@ * @ingroup Benchmark */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; function bfNormalizeTitleStrTr( $str ) { return strtr( $str, '_', ' ' ); @@ -75,4 +75,4 @@ class bench_strtr_str_replace extends Benchmarker { } $maintClass = 'bench_strtr_str_replace'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_utf8_title_check.php b/maintenance/benchmarks/bench_utf8_title_check.php index f5987800..078293eb 100644 --- a/maintenance/benchmarks/bench_utf8_title_check.php +++ b/maintenance/benchmarks/bench_utf8_title_check.php @@ -21,7 +21,7 @@ * @ingroup Benchmark */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * This little benchmark executes the regexp used in Language->checkTitleEncoding() @@ -38,7 +38,7 @@ class bench_utf8_title_check extends Benchmarker { public function __construct() { parent::__construct(); - $this->data = array ( + $this->data = array( "", "United States of America", // 7bit ASCII "S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e", @@ -123,4 +123,4 @@ class bench_utf8_title_check extends Benchmarker { } $maintClass = 'bench_utf8_title_check'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_wfBaseConvert.php b/maintenance/benchmarks/bench_wfBaseConvert.php index a1e5c6a4..f8a21562 100644 --- a/maintenance/benchmarks/bench_wfBaseConvert.php +++ b/maintenance/benchmarks/bench_wfBaseConvert.php @@ -22,7 +22,7 @@ * @author Tyler Romeo */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmarks wfBaseConvert(). @@ -74,4 +74,4 @@ class bench_wfBaseConvert extends Benchmarker { } $maintClass = 'bench_wfBaseConvert'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_wfIsWindows.php b/maintenance/benchmarks/bench_wfIsWindows.php index 85439827..1cd2016b 100644 --- a/maintenance/benchmarks/bench_wfIsWindows.php +++ b/maintenance/benchmarks/bench_wfIsWindows.php @@ -24,7 +24,7 @@ * @author Platonides */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmarks wfIsWindows(). @@ -66,4 +66,4 @@ class bench_wfIsWindows extends Benchmarker { } $maintClass = 'bench_wfIsWindows'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/benchmarkHooks.php b/maintenance/benchmarks/benchmarkHooks.php index fdb016f4..3f5d6db0 100644 --- a/maintenance/benchmarks/benchmarkHooks.php +++ b/maintenance/benchmarks/benchmarkHooks.php @@ -21,7 +21,7 @@ * @ingroup Benchmark */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmarks %MediaWiki hooks. @@ -84,4 +84,4 @@ class BenchmarkHooks extends Benchmarker { } $maintClass = 'BenchmarkHooks'; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/benchmarkPurge.php b/maintenance/benchmarks/benchmarkPurge.php index ec686b2a..fd863d52 100644 --- a/maintenance/benchmarks/benchmarkPurge.php +++ b/maintenance/benchmarks/benchmarkPurge.php @@ -21,7 +21,7 @@ * @ingroup Benchmark */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmarks Squid purge. @@ -112,4 +112,4 @@ class BenchmarkPurge extends Benchmarker { } $maintClass = "BenchmarkPurge"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; |