mirror of
https://github.com/spf13/viper
synced 2024-12-22 19:47:01 +00:00
Add BenchmarkGet
This commit is contained in:
parent
21ea37b673
commit
54b81535af
1 changed files with 12 additions and 0 deletions
|
@ -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.
|
// This is the "perfect result" for the above.
|
||||||
func BenchmarkGetBoolFromMap(b *testing.B) {
|
func BenchmarkGetBoolFromMap(b *testing.B) {
|
||||||
m := make(map[string]bool)
|
m := make(map[string]bool)
|
||||||
|
|
Loading…
Reference in a new issue