MediaWiki  1.23.8
bench_delete_truncate.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Benchmarker.php';
25 
32 
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = "Benchmarks SQL DELETE vs SQL TRUNCATE.";
36  }
37 
38  public function execute() {
39  $dbw = wfGetDB( DB_MASTER );
40 
41  $test = $dbw->tableName( 'test' );
42  $dbw->query( "CREATE TABLE IF NOT EXISTS /*_*/$test (
43  test_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
44  text varbinary(255) NOT NULL
45 );" );
46 
47  $this->insertData( $dbw );
48 
49  $start = microtime( true );
50 
51  $this->delete( $dbw );
52 
53  $end = microtime( true );
54 
55  echo "Delete: " . sprintf( "%6.3fms", ( $end - $start ) * 1000 );
56  echo "\r\n";
57 
58  $this->insertData( $dbw );
59 
60  $start = microtime( true );
61 
62  $this->truncate( $dbw );
63 
64  $end = microtime( true );
65 
66  echo "Truncate: " . sprintf( "%6.3fms", ( $end - $start ) * 1000 );
67  echo "\r\n";
68 
69  $dbw->dropTable( 'test' );
70  }
71 
76  private function insertData( $dbw ) {
77  $range = range( 0, 1024 );
78  $data = array();
79  foreach( $range as $r ) {
80  $data[] = array( 'text' => $r );
81  }
82  $dbw->insert( 'test', $data, __METHOD__ );
83  }
84 
89  private function delete( $dbw ) {
90  $dbw->delete( 'text', '*', __METHOD__ );
91  }
92 
97  private function truncate( $dbw ) {
98  $test = $dbw->tableName( 'test' );
99  $dbw->query( "TRUNCATE TABLE $test" );
100  }
101 }
102 
103 $maintClass = "BenchmarkDeleteTruncate";
104 require_once RUN_MAINTENANCE_IF_MAIN;
BenchmarkDeleteTruncate\truncate
truncate( $dbw)
Definition: bench_delete_truncate.php:97
BenchmarkDeleteTruncate\execute
execute()
Do the actual work.
Definition: bench_delete_truncate.php:38
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
BenchmarkDeleteTruncate\__construct
__construct()
Default constructor.
Definition: bench_delete_truncate.php:33
$test
$test
Definition: Utf8Test.php:89
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:37
$maintClass
$maintClass
Definition: bench_delete_truncate.php:103
BenchmarkDeleteTruncate
Maintenance script that benchmarks SQL DELETE vs SQL TRUNCATE.
Definition: bench_delete_truncate.php:31
BenchmarkDeleteTruncate\insertData
insertData( $dbw)
Definition: bench_delete_truncate.php:76
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9