Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2021 11:39
Show Gist options
  • Save percybolmer/8f5c3806c32a615c4ccef18c34181f09 to your computer and use it in GitHub Desktop.
Save percybolmer/8f5c3806c32a615c4ccef18c34181f09 to your computer and use it in GitHub Desktop.
// insertXPreallocIntMap is used to add X amount of items into a Map[int]int
func insertXPreallocIntMap(x int, b *testing.B) {
// Initialize Map and Insert X amount of items and Prealloc the size to X
testmap := make(map[int]int, x)
// Reset timer after Initalizing map, that's not what we want to test
b.ResetTimer()
for i := 0; i < x; i++ {
// Insert value of I into I key.
testmap[i] = i
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment