Index: trunk/extensions/VisualEditor/tests/parser/dumpGrepper.js |
— | — | @@ -59,10 +59,17 @@ |
60 | 60 | var re = new RegExp( argv._[0], flags ); |
61 | 61 | |
62 | 62 | var reader = new dumpReader.DumpReader(), |
63 | | - grepper = new DumpGrepper( re ); |
| 63 | + grepper = new DumpGrepper( re ), |
| 64 | + revisions = 0, |
| 65 | + matches = 0; |
64 | 66 | |
65 | | - reader.on( 'revision', grepper.grepRev.bind( grepper ) ); |
| 67 | + reader.on( 'revision', function ( revision ) { |
| 68 | + revisions++; |
| 69 | + grepper.grepRev( revision ); |
| 70 | + } ); |
| 71 | + |
66 | 72 | grepper.on( 'match', function ( revision, matches ) { |
| 73 | + matches++; |
67 | 74 | for ( var i = 0, l = matches.length; i < l; i++ ) { |
68 | 75 | console.log( '== Match: [[' + revision.page.title + ']] ==' ); |
69 | 76 | var m = matches[i]; |
— | — | @@ -80,8 +87,20 @@ |
81 | 88 | } |
82 | 89 | } |
83 | 90 | } ); |
| 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 | + |
84 | 101 | process.stdin.setEncoding('utf8'); |
85 | 102 | process.stdin.on('data', reader.push.bind(reader) ); |
86 | 103 | process.stdin.resume(); |
| 104 | + |
| 105 | + |
87 | 106 | } |
88 | 107 | |