Closed nejcokorn closed 6 years ago
Vary the parameters and see what affects it. Is lots of small stringifies concatenated faster than one big one? It wouldn't surprise me if one big one was faster, but then it also wouldn't surprise me if you got a non-linear slowdown once you got an input that was too big for JSON.stringify()
Streaming isn't actually about being faster, it's about using less resources at any one time. for example, JSONStream.parse is much slower, but you can parse objects with it that would cause out of memory errors with JSON.parse
Possibly you could do something clever here that used JSON.stringify in batches and get the best of both worlds (would be very happy to merge a PR for this), but we don't even have any performance tests currently.
I think this has been fixed. For me, the streaming is resulting in 40ms and non-stream version is taking > 1000ms.
I have tried using JSONStream.stringify() and noticed the performance actually bad. It takes 100x time to do the same thing I would do without streaming.
Please see the attached code below using JSONStream.
Using memory
Is this expected performance?