mirror of
https://github.com/gohugoio/hugo.git
synced 2025-05-06 02:36:21 +03:00
Adding benchmark for parsing pages using unicode.
The resulting comparsion is not equal because NewPage reads the file each time where ReadFrom just reads a buffer in memory.
This commit is contained in:
parent
085ce15f7c
commit
e67db666c8
2 changed files with 720 additions and 0 deletions
23
hugolib/benchmark_test.go
Normal file
23
hugolib/benchmark_test.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package hugolib
|
||||
|
||||
import (
|
||||
"os"
|
||||
"bytes"
|
||||
"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++ {
|
||||
ReadFrom(sample, "bench")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNewPage(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
NewPage("redis.cn.md")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue