Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
556 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var fs = require('fs'),
|
---|
| 2 | Parser = require('./jsonparse');
|
---|
| 3 |
|
---|
| 4 |
|
---|
| 5 | var json = fs.readFileSync("samplejson/basic.json");
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | while (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.