mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
f4c90bd6ba
commit
77c7059ff8
1 changed files with 55 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
package goldmark_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/gohugoio/hugo/hugolib"
|
||||
|
@ -59,3 +60,57 @@ foo
|
|||
<div class="highlight" id="c">
|
||||
`)
|
||||
}
|
||||
|
||||
func BenchmarkSiteWithRenderHooks(b *testing.B) {
|
||||
files := `
|
||||
-- config.toml --
|
||||
-- layouts/_default/_markup/render-heading.html --
|
||||
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
|
||||
{{ .Text | safeHTML }}
|
||||
<a class="anchor" href="#{{ .Anchor | safeURL }}">#</a>
|
||||
</h{{ .Level }}>
|
||||
-- layouts/_default/_markup/render-link.html --
|
||||
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
|
||||
-- layouts/_default/single.html --
|
||||
{{ .Content }}
|
||||
`
|
||||
|
||||
content := `
|
||||
|
||||
## Hello1 [Test](https://example.com)
|
||||
|
||||
A.
|
||||
|
||||
## Hello2 [Test](https://example.com)
|
||||
|
||||
B.
|
||||
|
||||
## Hello3 [Test](https://example.com)
|
||||
|
||||
C.
|
||||
|
||||
## Hello3 [Test](https://example.com)
|
||||
|
||||
D.
|
||||
`
|
||||
|
||||
for i := 1; i < 100; i++ {
|
||||
files += fmt.Sprintf("\n-- content/posts/p%d.md --\n"+content, i+1)
|
||||
}
|
||||
|
||||
cfg := hugolib.IntegrationTestConfig{
|
||||
T: b,
|
||||
TxtarString: files,
|
||||
}
|
||||
builders := make([]*hugolib.IntegrationTestBuilder, b.N)
|
||||
|
||||
for i := range builders {
|
||||
builders[i] = hugolib.NewIntegrationTestBuilder(cfg)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
builders[i].Build()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue