hugo/hugolib/benchmark_test.go
Noah Campbell 7461ed63ae Fix benchmark so the buffer is read each time.
The bytes.Buffer was exhausted after the first read.  Creating a new
reader each invocation catpures the correctly timing.
2013-08-23 14:16:37 -07:00

24 lines
391 B
Go

package hugolib
import (
"bytes"
"os"
"testing"
)
func BenchmarkParsePage(b *testing.B) {
f, _ := os.Open("redis.cn.md")
sample := new(bytes.Buffer)
sample.ReadFrom(f)
b.ResetTimer()
for i := 0; i < b.N; i++ {
p, _ := ReadFrom(bytes.NewReader(sample.Bytes()), "bench")
p = p
}
}
func BenchmarkNewPage(b *testing.B) {
for i := 0; i < b.N; i++ {
NewPage("redis.cn.md")
}
}