34 $title = Title::newFromText( $this->
getArg( 0 ) );
38 echo
"Starting from " . $lang->timeanddate( $start ) .
"\n";
40 $start =
'19700101000000';
49 $type = $this->
getOption(
'type', ConcatenatedGzipHistoryBlob::class );
54 $res = $revStore->newSelectQueryBuilder( $dbr )
58 'page_namespace' => $title->getNamespace(),
59 'page_title' => $title->getDBkey(),
60 $dbr->expr(
'rev_timestamp',
'>', $dbr->timestamp( $start ) ),
63 ->caller( __METHOD__ )->fetchResultSet();
68 $uncompressedSize = 0;
69 $tStart = ConvertibleTimestamp::hrtime();
70 foreach ( $res as $row ) {
71 $revRecord = $revStore->newRevisionFromRow( $row );
72 $text = $revRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )
75 $uncompressedSize += strlen( $text );
76 $hashes[$row->rev_id] = md5( $text );
77 $keys[$row->rev_id] = $blob->addItem( $text );
78 if ( $untilHappy && !$blob->isHappy() ) {
83 $serialized = serialize( $blob );
84 $t = ( ConvertibleTimestamp::hrtime() - $tStart ) / 1e9;
85 # print_r( $blob->mDiffMap );
87 printf(
"%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n",
90 $uncompressedSize / strlen( $serialized ),
91 $lang->formatSize( $uncompressedSize ),
94 printf(
"Compression time: %5.2f ms\n", $t * 1000 );
96 $tStart = ConvertibleTimestamp::hrtime();
97 $blob = unserialize( $serialized );
98 foreach ( $keys as $id => $key ) {
99 $text = $blob->getItem( $key );
100 if ( md5( $text ) != $hashes[$id] ) {
101 echo
"Content hash mismatch for rev_id $id\n";
105 $t = ( ConvertibleTimestamp::hrtime() - $tStart ) / 1e9;
106 printf(
"Decompression time: %5.2f ms\n", $t * 1000 );