Skip to content

Instantly share code, notes, and snippets.

@jeromewu
Last active June 11, 2021 07:12
Show Gist options
  • Save jeromewu/4f8c39db49e90dc39446cd4fc4727906 to your computer and use it in GitHub Desktop.
Save jeromewu/4f8c39db49e90dc39446cd4fc4727906 to your computer and use it in GitHub Desktop.
package main
import (
"testing"
)
const it = uint(1 << 24)
func BenchmarkSetWithBoolValueWrite(b *testing.B) {
set := make(map[uint]bool)
for i := uint(0); i < it; i++ {
set[i] = true
}
}
func BenchmarkSetWithStructValueWrite(b *testing.B) {
set := make(map[uint]struct{})
for i := uint(0); i < it; i++ {
set[i] = struct{}{}
}
}
func BenchmarkSetWithInterfaceValueWrite(b *testing.B) {
set := make(map[uint]interface{})
for i := uint(0); i < it; i++ {
set[i] = struct{}{}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment