44 $lang = $this->getServiceContainer()->getLanguageFactory()->getLanguage(
'en' );
45 $title = Title::newFromText( $this->getArg( 0 ) );
47 if ( $this->hasOption(
'start' ) ) {
48 $start =
wfTimestamp( TS_MW, strtotime( $this->getOption(
'start' ) ) );
49 echo
"Starting from " . $lang->timeanddate( $start ) .
"\n";
51 $start =
'19700101000000';
53 if ( $this->hasOption(
'limit' ) ) {
54 $limit = $this->getOption(
'limit' );
60 $type = $this->getOption(
'type', ConcatenatedGzipHistoryBlob::class );
62 $dbr = $this->getReplicaDB();
64 $revStore = $this->getServiceContainer()->getRevisionStore();
65 $res = $revStore->newSelectQueryBuilder( $dbr )
69 'page_namespace' => $title->getNamespace(),
70 'page_title' => $title->getDBkey(),
71 $dbr->expr(
'rev_timestamp',
'>', $dbr->timestamp( $start ) ),
74 ->caller( __FILE__ )->fetchResultSet();
79 $uncompressedSize = 0;
80 $t = -microtime(
true );
81 foreach ( $res as $row ) {
82 $revRecord = $revStore->newRevisionFromRow( $row );
83 $text = $revRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )
86 $uncompressedSize += strlen( $text );
87 $hashes[$row->rev_id] = md5( $text );
88 $keys[$row->rev_id] = $blob->addItem( $text );
89 if ( $untilHappy && !$blob->isHappy() ) {
94 $serialized = serialize( $blob );
95 $t += microtime(
true );
96 # print_r( $blob->mDiffMap );
98 printf(
"%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n",
101 $uncompressedSize / strlen( $serialized ),
102 $lang->formatSize( $uncompressedSize ),
103 strlen( $serialized )
105 printf(
"Compression time: %5.2f ms\n", $t * 1000 );
107 $t = -microtime(
true );
108 $blob = unserialize( $serialized );
109 foreach ( $keys as $id => $key ) {
110 $text = $blob->getItem( $key );
111 if ( md5( $text ) != $hashes[$id] ) {
112 echo
"Content hash mismatch for rev_id $id\n";
116 $t += microtime(
true );
117 printf(
"Decompression time: %5.2f ms\n", $t * 1000 );