add a benchmark for markdown

This commit is contained in:
Ted Unangst 2019-12-02 02:43:52 -05:00
parent 21aed53283
commit beaceaadb1
1 changed files with 20 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"strings"
"testing" "testing"
) )
@ -106,3 +107,22 @@ para
output := `hello<ul><li>a list<li>the list</ul><p>para<ul><li>singleton</ul><p>` output := `hello<ul><li>a list<li>the list</ul><p>para<ul><li>singleton</ul><p>`
doonezerotest(t, input, output) doonezerotest(t, input, output)
} }
var benchData, simpleData string
func init() {
benchData = strings.Repeat("hello there sir. It is a **fine** day for some testing!\n", 100)
simpleData = strings.Repeat("just a few words\n", 100)
}
func BenchmarkModerateSize(b *testing.B) {
for n := 0; n < b.N; n++ {
markitzero(benchData)
}
}
func BenchmarkSimpleData(b *testing.B) {
for n := 0; n < b.N; n++ {
markitzero(simpleData)
}
}