mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
parser: Add horizontal YAML tags to benchmark
This commit is contained in:
@ -322,8 +322,8 @@ func TestRemoveTOMLIdentifier(t *testing.T) {
|
|||||||
|
|
||||||
func BenchmarkFrontmatterTags(b *testing.B) {
|
func BenchmarkFrontmatterTags(b *testing.B) {
|
||||||
|
|
||||||
for _, frontmatter := range []string{"JSON", "YAML", "TOML"} {
|
for _, frontmatter := range []string{"JSON", "YAML", "YAML2", "TOML"} {
|
||||||
for i := 1; i < 30; i += 10 {
|
for i := 1; i < 60; i += 20 {
|
||||||
doBenchmarkFrontmatter(b, frontmatter, i)
|
doBenchmarkFrontmatter(b, frontmatter, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,6 +335,12 @@ name: "Tags"
|
|||||||
tags:
|
tags:
|
||||||
%s
|
%s
|
||||||
---
|
---
|
||||||
|
`
|
||||||
|
|
||||||
|
yaml2Template := `---
|
||||||
|
name: "Tags"
|
||||||
|
tags: %s
|
||||||
|
---
|
||||||
`
|
`
|
||||||
tomlTemplate := `+++
|
tomlTemplate := `+++
|
||||||
name = "Tags"
|
name = "Tags"
|
||||||
@ -364,6 +370,9 @@ tags = %s
|
|||||||
} else if fileformat == "JSON" {
|
} else if fileformat == "JSON" {
|
||||||
frontmatterTemplate = jsonTemplate
|
frontmatterTemplate = jsonTemplate
|
||||||
tagsStr = strings.Replace(fmt.Sprintf("%q", tags), " ", ", ", -1)
|
tagsStr = strings.Replace(fmt.Sprintf("%q", tags), " ", ", ", -1)
|
||||||
|
} else if fileformat == "YAML2" {
|
||||||
|
frontmatterTemplate = yaml2Template
|
||||||
|
tagsStr = strings.Replace(fmt.Sprintf("%q", tags), " ", ", ", -1)
|
||||||
} else {
|
} else {
|
||||||
frontmatterTemplate = yamlTemplate
|
frontmatterTemplate = yamlTemplate
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
|
Reference in New Issue
Block a user