33 $title = Title::newFromText( $this->
getArg( 0 ) );
37 echo
"Starting from " . $lang->timeanddate( $start ) .
"\n";
39 $start =
'19700101000000';
48 $type = $this->
getOption(
'type', ConcatenatedGzipHistoryBlob::class );
53 $res = $revStore->newSelectQueryBuilder( $dbr )
57 'page_namespace' => $title->getNamespace(),
58 'page_title' => $title->getDBkey(),
59 $dbr->expr(
'rev_timestamp',
'>', $dbr->timestamp( $start ) ),
62 ->caller( __FILE__ )->fetchResultSet();
67 $uncompressedSize = 0;
68 $t = -microtime(
true );
69 foreach ( $res as $row ) {
70 $revRecord = $revStore->newRevisionFromRow( $row );
71 $text = $revRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )
74 $uncompressedSize += strlen( $text );
75 $hashes[$row->rev_id] = md5( $text );
76 $keys[$row->rev_id] = $blob->addItem( $text );
77 if ( $untilHappy && !$blob->isHappy() ) {
82 $serialized = serialize( $blob );
83 $t += microtime(
true );
84 # print_r( $blob->mDiffMap );
86 printf(
"%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n",
89 $uncompressedSize / strlen( $serialized ),
90 $lang->formatSize( $uncompressedSize ),
93 printf(
"Compression time: %5.2f ms\n", $t * 1000 );
95 $t = -microtime(
true );
96 $blob = unserialize( $serialized );
97 foreach ( $keys as $id => $key ) {
98 $text = $blob->getItem( $key );
99 if ( md5( $text ) != $hashes[$id] ) {
100 echo
"Content hash mismatch for rev_id $id\n";
104 $t += microtime(
true );
105 printf(
"Decompression time: %5.2f ms\n", $t * 1000 );