Add BenchmarkGet

This commit is contained in:
Bjørn Erik Pedersen 2016-10-10 11:47:23 +02:00
parent 21ea37b673
commit 54b81535af
1 changed files with 12 additions and 0 deletions

View File

@ -966,6 +966,18 @@ func BenchmarkGetBool(b *testing.B) {
}
}
func BenchmarkGet(b *testing.B) {
key := "BenchmarkGet"
v = New()
v.Set(key, true)
for i := 0; i < b.N; i++ {
if !v.Get(key).(bool) {
b.Fatal("Get returned false")
}
}
}
// This is the "perfect result" for the above.
func BenchmarkGetBoolFromMap(b *testing.B) {
m := make(map[string]bool)