46 $title = Title::newFromText( $this->
getArg( 0 ) );
50 echo
"Starting from " . $lang->timeanddate( $start ) .
"\n";
52 $start =
'19700101000000';
61 $type = $this->
getOption(
'type', ConcatenatedGzipHistoryBlob::class );
66 $res = $revStore->newSelectQueryBuilder( $dbr )
70 'page_namespace' => $title->getNamespace(),
71 'page_title' => $title->getDBkey(),
72 $dbr->expr(
'rev_timestamp',
'>', $dbr->timestamp( $start ) ),
75 ->caller( __FILE__ )->fetchResultSet();
80 $uncompressedSize = 0;
81 $t = -microtime(
true );
82 foreach ( $res as $row ) {
83 $revRecord = $revStore->newRevisionFromRow( $row );
84 $text = $revRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )
87 $uncompressedSize += strlen( $text );
88 $hashes[$row->rev_id] = md5( $text );
89 $keys[$row->rev_id] = $blob->addItem( $text );
90 if ( $untilHappy && !$blob->isHappy() ) {
95 $serialized = serialize( $blob );
96 $t += microtime(
true );
97 # print_r( $blob->mDiffMap );
99 printf(
"%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n",
102 $uncompressedSize / strlen( $serialized ),
103 $lang->formatSize( $uncompressedSize ),
104 strlen( $serialized )
106 printf(
"Compression time: %5.2f ms\n", $t * 1000 );
108 $t = -microtime(
true );
109 $blob = unserialize( $serialized );
110 foreach ( $keys as $id => $key ) {
111 $text = $blob->getItem( $key );
112 if ( md5( $text ) != $hashes[$id] ) {
113 echo
"Content hash mismatch for rev_id $id\n";
117 $t += microtime(
true );
118 printf(
"Decompression time: %5.2f ms\n", $t * 1000 );