43 $title = Title::newFromText( $this->
getArg( 0 ) );
47 echo
"Starting from " . $lang->timeanddate( $start ) .
"\n";
49 $start =
'19700101000000';
58 $type = $this->
getOption(
'type', ConcatenatedGzipHistoryBlob::class );
63 $res = $revStore->newSelectQueryBuilder( $dbr )
67 'page_namespace' => $title->getNamespace(),
68 'page_title' => $title->getDBkey(),
69 $dbr->expr(
'rev_timestamp',
'>', $dbr->timestamp( $start ) ),
72 ->caller( __FILE__ )->fetchResultSet();
77 $uncompressedSize = 0;
78 $t = -microtime(
true );
79 foreach ( $res as $row ) {
80 $revRecord = $revStore->newRevisionFromRow( $row );
81 $text = $revRecord->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )
84 $uncompressedSize += strlen( $text );
85 $hashes[$row->rev_id] = md5( $text );
86 $keys[$row->rev_id] = $blob->addItem( $text );
87 if ( $untilHappy && !$blob->isHappy() ) {
92 $serialized = serialize( $blob );
93 $t += microtime(
true );
94 # print_r( $blob->mDiffMap );
96 printf(
"%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n",
99 $uncompressedSize / strlen( $serialized ),
100 $lang->formatSize( $uncompressedSize ),
101 strlen( $serialized )
103 printf(
"Compression time: %5.2f ms\n", $t * 1000 );
105 $t = -microtime(
true );
106 $blob = unserialize( $serialized );
107 foreach ( $keys as $id => $key ) {
108 $text = $blob->getItem( $key );
109 if ( md5( $text ) != $hashes[$id] ) {
110 echo
"Content hash mismatch for rev_id $id\n";
114 $t += microtime(
true );
115 printf(
"Decompression time: %5.2f ms\n", $t * 1000 );