Created
July 19, 2017 09:03
-
-
Save lloyd/ad6144b263a693154b808b2ed13ff5d1 to your computer and use it in GitHub Desktop.
maps vs slices for mapping small sets of ordinals to values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package whatever | |
import ( | |
"testing" | |
) | |
func BenchmarkMapConstruction(b *testing.B) { | |
space := make([]map[int][]string, b.N) | |
for n := 0; n < b.N; n++ { | |
space[n] = map[int][]string{ | |
0: []string{}, | |
1: []string{}, | |
2: []string{}, | |
3: []string{}, | |
} | |
} | |
} | |
func BenchmarkSliceConstruction(b *testing.B) { | |
space := make([][][]string, b.N) | |
for n := 0; n < b.N; n++ { | |
space[n] = make([][]string, 4) | |
} | |
} |
Author
lloyd
commented
Jul 19, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment