mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-26 12:13:43 +00:00
7461ed63ae
The bytes.Buffer was exhausted after the first read. Creating a new reader each invocation catpures the correctly timing.
24 lines
391 B
Go
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")
|
|
}
|
|
}
|