25require __DIR__ .
'/../commandLine.inc';
27if ( !isset(
$args[0] ) ) {
28 echo
"Usage: php testCompression.php [--type=<type>] [--start=<start-date>] " .
29 "[--limit=<num-revs>] <page-title>\n";
33$lang = Language::factory(
'en' );
35if ( isset( $options[
'start'] ) ) {
36 $start =
wfTimestamp( TS_MW, strtotime( $options[
'start'] ) );
37 echo
"Starting from " .
$lang->timeanddate( $start ) .
"\n";
39 $start =
'19700101000000';
41if ( isset( $options[
'limit'] ) ) {
42 $limit = $options[
'limit'];
48$type = $options[
'type'] ?? ConcatenatedGzipHistoryBlob::class;
56 'page_namespace' =>
$title->getNamespace(),
57 'page_title' =>
$title->getDBkey(),
58 'rev_timestamp > ' .
$dbr->addQuotes(
$dbr->timestamp( $start ) ),
61 [
'LIMIT' => $limit ],
69$t = -microtime(
true );
70foreach (
$res as $row ) {
72 $text = $revision->getSerializedData();
74 $hashes[$row->rev_id] = md5( $text );
82$t += microtime(
true );
83# print_r( $blob->mDiffMap );
85printf(
"%s\nCompression ratio for %d revisions: %5.2f, %s -> %d\n",
92printf(
"Compression time: %5.2f ms\n",
$t * 1000 );
94$t = -microtime(
true );
96foreach (
$keys as $id => $key ) {
97 $text =
$blob->getItem( $key );
98 if ( md5( $text ) !=
$hashes[$id] ) {
99 echo
"Content hash mismatch for rev_id $id\n";
103$t += microtime(
true );
104printf(
"Decompression time: %5.2f ms\n",
$t * 1000 );
unserialize( $serialized)
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
foreach( $res as $row) $serialized
if(!isset( $args[0])) $lang