mirror of
https://github.com/status-im/markdown.git
synced 2025-02-23 16:48:14 +00:00
Repeat a run of reference tests under benchmark
Will help with optimizing later on.
This commit is contained in:
parent
a9baf845f1
commit
c61b63f42c
53
ref_test.go
53
ref_test.go
@ -13,7 +13,11 @@
|
|||||||
|
|
||||||
package blackfriday
|
package blackfriday
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestReference(t *testing.T) {
|
func TestReference(t *testing.T) {
|
||||||
files := []string{
|
files := []string{
|
||||||
@ -70,3 +74,50 @@ func TestReference_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) {
|
|||||||
}
|
}
|
||||||
doTestsReference(t, files, NoEmptyLineBeforeBlock)
|
doTestsReference(t, files, NoEmptyLineBeforeBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// benchResultAnchor is an anchor variable to store the result of a benchmarked
|
||||||
|
// code so that compiler could never optimize away the call to runMarkdown()
|
||||||
|
var benchResultAnchor string
|
||||||
|
|
||||||
|
func BenchmarkReference(b *testing.B) {
|
||||||
|
params := TestParams{Options: Options{Extensions: NoExtensions}}
|
||||||
|
files := []string{
|
||||||
|
"Amps and angle encoding",
|
||||||
|
"Auto links",
|
||||||
|
"Backslash escapes",
|
||||||
|
"Blockquotes with code blocks",
|
||||||
|
"Code Blocks",
|
||||||
|
"Code Spans",
|
||||||
|
"Hard-wrapped paragraphs with list-like lines",
|
||||||
|
"Horizontal rules",
|
||||||
|
"Inline HTML (Advanced)",
|
||||||
|
"Inline HTML (Simple)",
|
||||||
|
"Inline HTML comments",
|
||||||
|
"Links, inline style",
|
||||||
|
"Links, reference style",
|
||||||
|
"Links, shortcut references",
|
||||||
|
"Literal quotes in titles",
|
||||||
|
"Markdown Documentation - Basics",
|
||||||
|
"Markdown Documentation - Syntax",
|
||||||
|
"Nested blockquotes",
|
||||||
|
"Ordered and unordered lists",
|
||||||
|
"Strong and em together",
|
||||||
|
"Tabs",
|
||||||
|
"Tidyness",
|
||||||
|
}
|
||||||
|
var tests []string
|
||||||
|
for _, basename := range files {
|
||||||
|
filename := filepath.Join("testdata", basename+".text")
|
||||||
|
inputBytes, err := ioutil.ReadFile(filename)
|
||||||
|
if err != nil {
|
||||||
|
b.Errorf("Couldn't open '%s', error: %v\n", filename, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tests = append(tests, string(inputBytes))
|
||||||
|
}
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
for _, test := range tests {
|
||||||
|
benchResultAnchor = runMarkdown(test, params)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user