Skip to content

Instantly share code, notes, and snippets.

@teivah
Created July 3, 2020 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teivah/1f1df0157ff1e1bff3b7f789bf4e33fa to your computer and use it in GitHub Desktop.
Save teivah/1f1df0157ff1e1bff3b7f789bf4e33fa to your computer and use it in GitHub Desktop.
const size = 512
var result int64
func Benchmark8Size(b *testing.B) {
const arraySize = 8
s := make([][arraySize]int64, size)
var r int64
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := 0; j < size; j++ {
ss := s[j]
for k := 0; k < arraySize; k++ {
r = ss[k]
}
}
}
result = r
}
func Benchmark9Size(b *testing.B) {
const arraySize = 9
s := make([][arraySize]int64, size)
var r int64
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := 0; j < size; j++ {
ss := s[j]
for k := 0; k < arraySize; k++ {
r = ss[k]
}
}
}
result = r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment