Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This removes two allocations per unique metric, and improves run times considerably
$ benchstat bench-old bench-new
name old time/op new time/op delta
Int64Sum/count-10-4 7.81µs ±37% 3.29µs ± 5% -57.85% (p=0.000 n=10+10)
Int64Sum/count-50-4 36.1µs ±31% 15.6µs ± 7% -56.85% (p=0.000 n=10+10)
Int64Sum/count-100-4 64.7µs ± 5% 31.0µs ± 4% -52.17% (p=0.000 n=8+10)
Float64Sum/count-10-4 8.22µs ±31% 3.50µs ± 2% -57.45% (p=0.000 n=10+10)
Float64Sum/count-50-4 36.2µs ±29% 16.6µs ± 5% -54.13% (p=0.000 n=9+10)
Float64Sum/count-100-4 69.9µs ±15% 33.3µs ± 4% -52.37% (p=0.000 n=8+10)
Int64SumParallel-4 11.4ms ±19% 0.0ms ±51% -99.59% (p=0.000 n=9+10)
Float64SumParallel-4 12.3ms ±31% 0.1ms ±60% -99.57% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
Int64Sum/count-10-4 1.57kB ± 0% 0.50kB ± 0% -67.98% (p=0.000 n=10+10)
Int64Sum/count-50-4 6.88kB ± 0% 2.85kB ± 0% -58.63% (p=0.000 n=10+10)
Int64Sum/count-100-4 13.8kB ± 0% 5.2kB ± 0% -62.15% (p=0.000 n=10+9)
Float64Sum/count-10-4 1.65kB ± 0% 0.58kB ± 0% -64.68% (p=0.000 n=10+10)
Float64Sum/count-50-4 7.28kB ± 0% 3.25kB ± 0% -55.42% (p=0.000 n=10+10)
Float64Sum/count-100-4 14.6kB ± 0% 6.0kB ± 0% -58.75% (p=0.000 n=9+10)
Int64SumParallel-4 11.9kB ±17% 1.0kB ±20% -91.49% (p=0.000 n=10+10)
Float64SumParallel-4 12.0kB ±19% 1.2kB ±25% -89.91% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
Int64Sum/count-10-4 46.0 ± 0% 12.0 ± 0% -73.91% (p=0.000 n=10+10)
Int64Sum/count-50-4 208 ± 0% 52 ± 0% -75.00% (p=0.000 n=10+10)
Int64Sum/count-100-4 409 ± 0% 102 ± 0% -75.06% (p=0.000 n=10+10)
Float64Sum/count-10-4 56.0 ± 0% 22.0 ± 0% -60.71% (p=0.000 n=10+10)
Float64Sum/count-50-4 258 ± 0% 102 ± 0% -60.47% (p=0.000 n=10+10)
Float64Sum/count-100-4 509 ± 0% 202 ± 0% -60.31% (p=0.000 n=10+10)
Int64SumParallel-4 387 ±18% 20 ±21% -94.88% (p=0.000 n=10+10)
Float64SumParallel-4 406 ±19% 41 ±25% -89.92% (p=0.000 n=10+10)