Added new benchmark for typical scenario of usage of WindowedHistogram (rotate and merge every tick) with a large window of 100 histograms with 100k values in each:
BenchmarkWindowedHistogramRotateAndMerge
Before optimization: 8737304 ns/op (8.7 ms)
After optimization: 183992 ns/op (0.2 ms)
Note that calling Merge after Rotate is not needed anymore.
Rotate now returns already merged histogram, using it's result provides ability to achieve maximum performance.
Merge still can be used at any time to get immediate representation of the whole histogram, including current histogram which has not been rotated yet. But there is no much practical use of this function.
Added new benchmark for typical scenario of usage of WindowedHistogram (rotate and merge every tick) with a large window of 100 histograms with 100k values in each: BenchmarkWindowedHistogramRotateAndMerge
Result on my MacBook Pro 13 before optimization:
Result on my MacBook Pro 13 after optimization:
Before optimization: 8737304 ns/op (8.7 ms) After optimization: 183992 ns/op (0.2 ms)
Note that calling Merge after Rotate is not needed anymore. Rotate now returns already merged histogram, using it's result provides ability to achieve maximum performance. Merge still can be used at any time to get immediate representation of the whole histogram, including current histogram which has not been rotated yet. But there is no much practical use of this function.