Double the size of slice in BenchmarkSum2

It's unfair that `BenchmarkLinkedList` iterates n count but `BenchmarkSum2` iterates n/2 count because `i+=2` in `sum2`.
This commit is contained in:
Victor 2026-03-02 01:01:15 +08:00 committed by GitHub
parent ab425833b5
commit e4df08796d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,7 @@ func BenchmarkSum2(b *testing.B) {
var local int64
for i := 0; i < b.N; i++ {
b.StopTimer()
s := make([]int64, n)
s := make([]int64, n*2)
b.StartTimer()
local = sum2(s)
}