var fs = require('fs'), Parser = require('./jsonparse'); var json = fs.readFileSync("samplejson/basic.json"); while (true) { var start = Date.now(); for (var i = 0; i < 1000; i++) { JSON.parse(json); } var first = Date.now() - start; start = Date.now(); var p = new Parser(); for (var i = 0; i < 1000; i++) { p.write(json); } var second = Date.now() - start; console.log("JSON.parse took %s", first); console.log("streaming parser took %s", second); console.log("streaming is %s times slower", second / first); }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
examples | Folder | 0755 |
|
|
samplejson | Folder | 0755 |
|
|
LICENSE | File | 1.06 KB | 0644 |
|
bench.js | File | 556 B | 0644 |
|
jsonparse.js | File | 15.21 KB | 0644 |
|
package.json | File | 551 B | 0644 |
|