aboutsummaryrefslogtreecommitdiff
path: root/func_test.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-19 15:46:21 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-19 15:46:21 +0900
commit77411fb4bdcab6222a51ef1a4a0f625b7f4a4523 (patch)
tree1feb5e408d621b5ddba50388ca465b6b1984d14b /func_test.go
parentce14acbe573bdf2853e67ea418940e835c07409b (diff)
downloadkati-77411fb4bdcab6222a51ef1a4a0f625b7f4a4523.tar.gz
reduce allocation in funcPatsubst
benchmark old ns/op new ns/op delta BenchmarkFuncPatsubst 2030 1102 -45.71% benchmark old allocs new allocs delta BenchmarkFuncPatsubst 9 1 -88.89% benchmark old bytes new bytes delta BenchmarkFuncPatsubst 297 32 -89.23%
Diffstat (limited to 'func_test.go')
-rw-r--r--func_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/func_test.go b/func_test.go
index 7fae5f2..6758a9b 100644
--- a/func_test.go
+++ b/func_test.go
@@ -56,3 +56,24 @@ func BenchmarkFuncSort(b *testing.B) {
sort.Eval(&buf, ev)
}
}
+
+func BenchmarkFuncPatsubst(b *testing.B) {
+ patsubst := &funcPatsubst{
+ fclosure: fclosure{
+ args: []Value{
+ literal("(patsubst"),
+ literal("%.java"),
+ literal("%.class"),
+ literal("foo.jar bar.java baz.h"),
+ },
+ },
+ }
+ ev := newEvaluator(make(map[string]Var))
+ var buf bytes.Buffer
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ buf.Reset()
+ patsubst.Eval(&buf, ev)
+ }
+}