X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fstorage%2FtestCompression.php;h=90d8d03110708b155e5e623c5a1b6ac94b5240cd;hb=3cb14f56bdf3271769a5866f9dcaad56bf873aea;hp=d693986cb87de90160769bacb9ea80fcec6e2a3b;hpb=580d6f42d9835e5e64477c7f69fcd06787e9297f;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/storage/testCompression.php b/maintenance/storage/testCompression.php index d693986cb8..90d8d03110 100644 --- a/maintenance/storage/testCompression.php +++ b/maintenance/storage/testCompression.php @@ -21,18 +21,20 @@ * @ingroup Maintenance ExternalStorage */ -$optionsWithArgs = array( 'start', 'limit', 'type' ); +$optionsWithArgs = [ 'start', 'limit', 'type' ]; require __DIR__ . '/../commandLine.inc'; -if ( !isset( $args[0] ) ) { - echo "Usage: php testCompression.php [--type=] [--start=] [--limit=] \n"; +if ( !isset( $args[0] ) ) { + echo "Usage: php testCompression.php [--type=] [--start=] " . + "[--limit=] \n"; exit( 1 ); } +$lang = Language::factory( 'en' ); $title = Title::newFromText( $args[0] ); if ( isset( $options['start'] ) ) { $start = wfTimestamp( TS_MW, strtotime( $options['start'] ) ); - echo "Starting from " . $wgLang->timeanddate( $start ) . "\n"; + echo "Starting from " . $lang->timeanddate( $start ) . "\n"; } else { $start = '19700101000000'; } @@ -45,22 +47,22 @@ if ( isset( $options['limit'] ) ) { } $type = isset( $options['type'] ) ? $options['type'] : 'ConcatenatedGzipHistoryBlob'; -$dbr = wfGetDB( DB_SLAVE ); +$dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( - array( 'page', 'revision', 'text' ), + [ 'page', 'revision', 'text' ], '*', - array( + [ 'page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey(), 'page_id=rev_page', 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $start ) ), 'rev_text_id=old_id' - ), __FILE__, array( 'LIMIT' => $limit ) + ], __FILE__, [ 'LIMIT' => $limit ] ); $blob = new $type; -$hashes = array(); -$keys = array(); +$hashes = []; +$keys = []; $uncompressedSize = 0; $t = -microtime( true ); foreach ( $res as $row ) { @@ -82,7 +84,7 @@ printf( "%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n", $type, count( $hashes ), $uncompressedSize / strlen( $serialized ), - $wgLang->formatSize( $uncompressedSize ), + $lang->formatSize( $uncompressedSize ), strlen( $serialized ) ); printf( "Compression time: %5.2f ms\n", $t * 1000 );