summaryrefslogtreecommitdiffstats
path: root/transform/chain_test.go
diff options
context:
space:
mode:
authorNoah Campbell <noahcampbell@gmail.com>2013-10-31 22:14:11 -0700
committerNoah Campbell <noahcampbell@gmail.com>2013-11-01 09:59:57 -0700
commit9af47f07d3f9700e233a98d7e84d85c3a30f9cd5 (patch)
tree13df4879bf1bf5f895d74029086dfce5a6b60c04 /transform/chain_test.go
parentf4cb8e1688b1459472413f3c85cb3b6297397020 (diff)
Improve rendering time
50% speedup. Fix #91 to run the benchmark: go test -test.run=NONE -bench=".*" -test.benchmem=true ./transform/ > new.txt to compare the results: /usr/local/go/misc/benchcmp baseline.txt new.txt Speedup and memory improvements benchmark old ns/op new ns/op delta BenchmarkChain 101219 50453 -50.15% BenchmarkTransform 51625 45531 -11.80% benchmark old allocs new allocs delta BenchmarkChain 222 103 -53.60% BenchmarkTransform 135 106 -21.48% benchmark old bytes new bytes delta BenchmarkChain 23919 10998 -54.02% BenchmarkTransform 11858 10665 -10.06%
Diffstat (limited to 'transform/chain_test.go')
-rw-r--r--transform/chain_test.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/transform/chain_test.go b/transform/chain_test.go
index b479ac1e3..594b5a5d4 100644
--- a/transform/chain_test.go
+++ b/transform/chain_test.go
@@ -15,7 +15,8 @@ func TestChainZeroTransformers(t *testing.T) {
}
func TestChainOneTransformer(t *testing.T) {
- tr := NewChain(&AbsURL{BaseURL: "http://base"})
+ absURL, _ := AbsURL("http://base")
+ tr := NewChain(absURL...)
apply(t.Errorf, tr, abs_url_tests)
}
@@ -28,19 +29,19 @@ var two_chain_tests = []test{
}
func TestChainTwoTransformer(t *testing.T) {
- tr := NewChain(
- &AbsURL{BaseURL: "http://two"},
- &NavActive{Section: "section_1"},
- )
+ absURL, _ := AbsURL("http://two")
+ nav := NavActive("section_1", "hugo-nav")
+ tr := NewChain(append(absURL, nav...)...)
apply(t.Errorf, tr, two_chain_tests)
}
func BenchmarkChain(b *testing.B) {
- tr := NewChain(
- &AbsURL{BaseURL: "http://two"},
- &NavActive{Section: "section_1"},
- )
+ absURL, _ := AbsURL("http://two")
+ nav := NavActive("section_1", "hugo-nav")
+ tr := NewChain(append(absURL, nav...)...)
+
+ b.ResetTimer()
for i := 0; i < b.N; i++ {
apply(b.Errorf, tr, two_chain_tests)
}