I don't know if I'm doing this right, but the jsonStream.stringifyObject() stream seems to take about 150% of the time of a normal JSON.stringify().
var obj = require('./test.json');
var now = require('performance-now');
var fs = require('fs');
var jsonStream = require('JSONStream');
var t, j;
t = now();
j = JSON.stringify(obj);
console.log(now() - t);
t = now();
j = jsonStream.stringifyObject();
for (key in obj)
j.write([key, obj[key]]);
j.end();
console.log(now() - t);
I was hoping to speed up the process of gzipping objects by stringifying them. But even if the stream means I can start gzipping before the stream is done, the overhead is significant.
I am guessing this might only be beneficial for memory preservation purposes?
It would be nice to see some benchmarks for proper scenarios.
I don't know if I'm doing this right, but the
jsonStream.stringifyObject()
stream seems to take about 150% of the time of a normalJSON.stringify()
.I was hoping to speed up the process of gzipping objects by stringifying them. But even if the stream means I can start gzipping before the stream is done, the overhead is significant.
I am guessing this might only be beneficial for memory preservation purposes?
It would be nice to see some benchmarks for proper scenarios.