MediaWiki  1.23.8
testCompression.php
Go to the documentation of this file.
1 <?php
24 $optionsWithArgs = array( 'start', 'limit', 'type' );
25 require __DIR__ . '/../commandLine.inc';
26 
27 if ( !isset( $args[0] ) ) {
28  echo "Usage: php testCompression.php [--type=<type>] [--start=<start-date>] [--limit=<num-revs>] <page-title>\n";
29  exit( 1 );
30 }
31 
33 if ( isset( $options['start'] ) ) {
34  $start = wfTimestamp( TS_MW, strtotime( $options['start'] ) );
35  echo "Starting from " . $wgLang->timeanddate( $start ) . "\n";
36 } else {
37  $start = '19700101000000';
38 }
39 if ( isset( $options['limit'] ) ) {
40  $limit = $options['limit'];
41  $untilHappy = false;
42 } else {
43  $limit = 1000;
44  $untilHappy = true;
45 }
46 $type = isset( $options['type'] ) ? $options['type'] : 'ConcatenatedGzipHistoryBlob';
47 
49 $res = $dbr->select(
50  array( 'page', 'revision', 'text' ),
51  '*',
52  array(
53  'page_namespace' => $title->getNamespace(),
54  'page_title' => $title->getDBkey(),
55  'page_id=rev_page',
56  'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $start ) ),
57  'rev_text_id=old_id'
58  ), __FILE__, array( 'LIMIT' => $limit )
59 );
60 
61 $blob = new $type;
65 $t = -microtime( true );
66 foreach ( $res as $row ) {
67  $revision = new Revision( $row );
68  $text = $revision->getSerializedData();
69  $uncompressedSize += strlen( $text );
70  $hashes[$row->rev_id] = md5( $text );
71  $keys[$row->rev_id] = $blob->addItem( $text );
72  if ( $untilHappy && !$blob->isHappy() ) {
73  break;
74  }
75 }
76 
77 $serialized = serialize( $blob );
78 $t += microtime( true );
79 # print_r( $blob->mDiffMap );
80 
81 printf( "%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n",
82  $type,
83  count( $hashes ),
84  $uncompressedSize / strlen( $serialized ),
85  $wgLang->formatSize( $uncompressedSize ),
86  strlen( $serialized )
87 );
88 printf( "Compression time: %5.2f ms\n", $t * 1000 );
89 
90 $t = -microtime( true );
91 $blob = unserialize( $serialized );
92 foreach ( $keys as $id => $key ) {
93  $text = $blob->getItem( $key );
94  if ( md5( $text ) != $hashes[$id] ) {
95  echo "Content hash mismatch for rev_id $id\n";
96  # var_dump( $text );
97  }
98 }
99 $t += microtime( true );
100 printf( "Decompression time: %5.2f ms\n", $t * 1000 );
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
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
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
$serialized
foreach( $res as $row) $serialized
Definition: testCompression.php:77
$limit
if( $sleep) $limit
Definition: importImages.php:99
$res
$res
Definition: testCompression.php:49
$dbr
$dbr
Definition: testCompression.php:48
Revision
Definition: Revision.php:26
$blob
$blob
Definition: testCompression.php:61
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
TS_MW
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Definition: GlobalFunctions.php:2431
$args
if( $line===false) $args
Definition: cdb.php:62
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
$title
if(!isset( $args[0])) $title
Definition: testCompression.php:32
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
$keys
$keys
Definition: testCompression.php:63
$uncompressedSize
$uncompressedSize
Definition: testCompression.php:64
$hashes
$hashes
Definition: testCompression.php:62
$t
$t
Definition: testCompression.php:65
$optionsWithArgs
$optionsWithArgs
Definition: testCompression.php:24
$untilHappy
$untilHappy
Definition: testCompression.php:44
$type
$type
Definition: testCompression.php:46