Skip to content

Commit

Permalink
markup/goldmark: Add BenchmarkCodeblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Feb 21, 2022
1 parent bddcfd9 commit 4ada094
Showing 1 changed file with 80 additions and 2 deletions.
82 changes: 80 additions & 2 deletions markup/goldmark/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package goldmark_test

import (
"fmt"
"strings"
"testing"

"github.com/gohugoio/hugo/hugolib"
Expand Down Expand Up @@ -131,7 +132,7 @@ title: "p1"
)
}

func BenchmarkSiteWithRenderHooks(b *testing.B) {
func BenchmarkRenderHooks(b *testing.B) {
files := `
-- config.toml --
-- layouts/_default/_markup/render-heading.html --
Expand Down Expand Up @@ -159,11 +160,88 @@ B.
C.
## Hello3 [Test](https://example.com)
## Hello4 [Test](https://example.com)
D.
[Test](https://example.com)
## Hello5
`

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()
}
}

func BenchmarkCodeblocks(b *testing.B) {
files := `
-- config.toml --
[markup]
[markup.highlight]
anchorLineNos = false
codeFences = true
guessSyntax = false
hl_Lines = ''
lineAnchors = ''
lineNoStart = 1
lineNos = false
lineNumbersInTable = true
noClasses = true
style = 'monokai'
tabWidth = 4
-- layouts/_default/single.html --
{{ .Content }}
`

content := `
FENCEgo
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
FENCE
FENCEbash
#!/bin/bash
# Usage: Hello World Bash Shell Script Using Variables
# Author: Vivek Gite
# -------------------------------------------------
# Define bash shell variable called var
# Avoid spaces around the assignment operator (=)
var="Hello World"
# print it
echo "$var"
# Another way of printing it
printf "%s\n" "$var"
FENCE
`

content = strings.ReplaceAll(content, "FENCE", "```")

for i := 1; i < 100; i++ {
files += fmt.Sprintf("\n-- content/posts/p%d.md --\n"+content, i+1)
}
Expand Down

0 comments on commit 4ada094

Please sign in to comment.