config: add benchmark for replace walker

This commit is contained in:
Mitchell Hashimoto 2014-05-24 11:35:15 -07:00
parent 2ecf1b500f
commit 27c97b9b73
1 changed files with 18 additions and 0 deletions

View File

@ -18,6 +18,24 @@ func BenchmarkVariableDetectWalker(b *testing.B) {
} }
} }
func BenchmarkVariableReplaceWalker(b *testing.B) {
w := &variableReplaceWalker{
Values: map[string]string{
"var.bar": "bar",
"bar.baz.bing": "baz",
},
}
str := `foo ${var.bar} bar ${bar.baz.bing} $${escaped}`
b.ResetTimer()
for i := 0; i < b.N; i++ {
if err := reflectwalk.Walk(&str, w); err != nil {
panic(err)
}
}
}
func TestVariableDetectWalker(t *testing.T) { func TestVariableDetectWalker(t *testing.T) {
w := new(variableDetectWalker) w := new(variableDetectWalker)