Last active
August 29, 2015 14:12
-
-
Save bmeck/f5e3f4ece683af6744e1 to your computer and use it in GitHub Desktop.
attempt to find repro for Jan-'s problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // usage: node this-file.js file-to-read | |
| stream=require('fs').createReadStream(process.argv[2]); | |
| var to_read = 315208358; | |
| var max_chunk = Math.pow(2,17); | |
| var largest_chunk = 0; | |
| var total_read = 0; | |
| stream.on('readable', function () { | |
| console.log('readable') | |
| var b=stream.read(Math.min(max_chunk, to_read - total_read)) | |
| while(b != null && to_read) { | |
| largest_chunk = Math.max(b.length, largest_chunk); | |
| total_read += b.length; | |
| console.log('read %d bytes total=%d %d%%', b.length, total_read, total_read/to_read) | |
| b=stream.read(Math.min(max_chunk, to_read - total_read)) | |
| } | |
| }); | |
| stream.on('end', function () { | |
| console.log('DONE'); | |
| console.log('MAX CHUNK EXPECTED=%d ACTUAL=%d', max_chunk, largest_chunk); | |
| console.log('READ EXPECTED=%d ACTUAL=%d', to_read, total_read) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment