Created
November 5, 2010 16:34
-
-
Save andykent/664408 to your computer and use it in GitHub Desktop.
Test Case that shows a high number of writes getting mangled along with a file to scan over and validate the data.
This file contains 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
var fs = require('fs'); | |
var lines = fs.readFileSync('output.json', 'utf8').split("\n"); | |
lines.pop(); // remove the last (empty) new line | |
for(var n in lines) { | |
try { | |
JSON.parse(lines[n]); | |
} catch (e) { | |
console.log("Error at line " + (n+1) + " => " + lines[n]); | |
} | |
} |
This file contains 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
var fs = require('fs'); | |
var fd = fs.openSync('output.json', 'a'); | |
var i = 0; | |
while (i < 100000) fs.write(fd, JSON.stringify({ foo: 'bar', iteration: i++ })+"\n"); | |
fs.closeSync(fd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment