source: trip-planner-front/node_modules/jsonparse/bench.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 556 bytes
Line 
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}
Note: See TracBrowser for help on using the repository browser.