Speed up JSON output (#1114)
Speed up JSON output (#1114)

* perf(jsonOutput): speed up json output

The commit includes three main changes:
1. Don't write on Collect instead (as all other outputs) append to a
buffer and write the buffer in a separate goroutine every 100
milliseconds
2. Use json.Encoder for speed up
3. If the output file ends in `.gz` gzip the output which in my testing
decreases the file size by 30x. I couldn't measure any performance
degradation from the fact we need to compress if anything there is some
performance gain because of the smaller io writes

I was testing with simple script doing batch requests for a local zero
length file with 40VUS, that makes around 8k RPS using around 600-700mb
of memory. When running before those I was getting 5.8-6k RPS, after
this I am getting 6.5-6.9k RPS with around 3GB of memory usage.

At this point my cpu and memory profiling shows that the problem is the
json encoding upwards of 10 seconds and as such the next possible
optimizations are in using some kind of faster json encoding.

loadimpact/k6,loadimpact/k6