X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2Fbenchmarks%2Fbench_delete_truncate.php;h=0a999ecca1a9d0dcee5291b7ff7c7ae5a1df69df;hp=2369d993ea4e61e91d7c39e90575f0f60b9a9463;hb=89539f2aa1b158fdcc703ad053e2580cb97a6385;hpb=e0b6258185e05cfc20c7b084bb8e9af650196cda diff --git a/maintenance/benchmarks/bench_delete_truncate.php b/maintenance/benchmarks/bench_delete_truncate.php index 2369d993ea..0a999ecca1 100644 --- a/maintenance/benchmarks/bench_delete_truncate.php +++ b/maintenance/benchmarks/bench_delete_truncate.php @@ -32,6 +32,8 @@ use Wikimedia\Rdbms\IMaintainableDatabase; * @ingroup Benchmark */ class BenchmarkDeleteTruncate extends Benchmarker { + protected $defaultCount = 10; + public function __construct() { parent::__construct(); $this->addDescription( 'Benchmarks SQL DELETE vs SQL TRUNCATE.' ); @@ -46,27 +48,24 @@ class BenchmarkDeleteTruncate extends Benchmarker { text varbinary(255) NOT NULL );" ); - $this->insertData( $dbw ); - - $start = microtime( true ); - - $this->delete( $dbw ); - - $end = microtime( true ); - - echo "Delete: " . sprintf( "%6.3fms", ( $end - $start ) * 1000 ); - echo "\r\n"; - - $this->insertData( $dbw ); - - $start = microtime( true ); - - $this->truncate( $dbw ); - - $end = microtime( true ); - - echo "Truncate: " . sprintf( "%6.3fms", ( $end - $start ) * 1000 ); - echo "\r\n"; + $this->bench( [ + 'Delete' => [ + 'setup' => function () use ( $dbw ) { + $this->insertData( $dbw ); + }, + 'function' => function () use ( $dbw ) { + $this->delete( $dbw ); + } + ], + 'Truncate' => [ + 'setup' => function () use ( $dbw ) { + $this->insertData( $dbw ); + }, + 'function' => function () use ( $dbw ) { + $this->truncate( $dbw ); + } + ] + ] ); $dbw->dropTable( 'test' ); } @@ -102,5 +101,5 @@ class BenchmarkDeleteTruncate extends Benchmarker { } } -$maintClass = "BenchmarkDeleteTruncate"; +$maintClass = 'BenchmarkDeleteTruncate'; require_once RUN_MAINTENANCE_IF_MAIN;