r112818 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112817‎ | r112818 | r112819 >
Date:16:42, 1 March 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Collect some statistics while grepping.
Modified paths:
  • /trunk/extensions/VisualEditor/tests/parser/dumpGrepper.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/dumpGrepper.js
@@ -59,10 +59,17 @@
6060 var re = new RegExp( argv._[0], flags );
6161
6262 var reader = new dumpReader.DumpReader(),
63 - grepper = new DumpGrepper( re );
 63+ grepper = new DumpGrepper( re ),
 64+ revisions = 0,
 65+ matches = 0;
6466
65 - reader.on( 'revision', grepper.grepRev.bind( grepper ) );
 67+ reader.on( 'revision', function ( revision ) {
 68+ revisions++;
 69+ grepper.grepRev( revision );
 70+ } );
 71+
6672 grepper.on( 'match', function ( revision, matches ) {
 73+ matches++;
6774 for ( var i = 0, l = matches.length; i < l; i++ ) {
6875 console.log( '== Match: [[' + revision.page.title + ']] ==' );
6976 var m = matches[i];
@@ -80,8 +87,20 @@
8188 }
8289 }
8390 } );
 91+
 92+ process.stdin.on ( 'end' , function() {
 93+ // Print some stats
 94+ console.log( '################################################' );
 95+ console.log( 'Total revisions: ' + revisions );
 96+ console.log( 'Total matches: ' + matches );
 97+ console.log( 'Ratio: ' + (matches / revisions * 100) + '%' );
 98+ console.log( '################################################' );
 99+ } );
 100+
84101 process.stdin.setEncoding('utf8');
85102 process.stdin.on('data', reader.push.bind(reader) );
86103 process.stdin.resume();
 104+
 105+
87106 }
88107

Status & tagging log