• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var fs = require('fs'),
2    Parser = require('./jsonparse');
3
4
5var json = fs.readFileSync("samplejson/basic.json");
6
7
8while (true) {
9  var start = Date.now();
10  for (var i = 0; i < 1000; i++) {
11    JSON.parse(json);
12  }
13  var first = Date.now() - start;
14
15  start = Date.now();
16  var p = new Parser();
17  for (var i = 0; i < 1000; i++) {
18    p.write(json);
19  }
20  var second = Date.now() - start;
21
22
23  console.log("JSON.parse took %s", first);
24  console.log("streaming parser took %s", second);
25  console.log("streaming is %s times slower", second / first);
26}
27