Skip to content

Instantly share code, notes, and snippets.

@capoferro
Created September 17, 2014 22:48
Show Gist options
  • Save capoferro/2e957b25080ad1e7726f to your computer and use it in GitHub Desktop.
Save capoferro/2e957b25080ad1e7726f to your computer and use it in GitHub Desktop.
package main
import (
"testing"
)
func BenchmarkAaa(b *testing.B) {
ints := make([]int, 0)
for i := 0; i < b.N; i++ {
ints = append(ints, i)
}
}
func BenchmarkBbb(b *testing.B) {
ints := make([]int, b.N)
for i := 0; i < b.N; i++ {
ints[i] = i
}
}
@capoferro
Copy link
Author

For some reason flipping the run order of the benchmarks makes Aaa take much longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment