publisher: Add benchmark

This commit is contained in:
Bjørn Erik Pedersen 2023-02-05 16:39:31 +01:00
parent 76c6140c52
commit 4f4a1c00bf
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F

View file

@ -214,3 +214,26 @@ func BenchmarkElementsCollectorWriter(b *testing.B) {
} }
} }
func BenchmarkElementsCollectorWriterPre(b *testing.B) {
const benchHTML = `
<pre class="preclass">
<span>foo</span><span>bar</span>
<!-- many more span elements -->
<span class="foo">foo</span>
<span class="bar">bar</span>
<span class="baz">baz</span>
<span class="qux">qux</span>
<span class="quux">quux</span>
<span class="quuz">quuz</span>
<span class="corge">corge</span>
</pre>
<div class="foo"></div>
`
w := newHTMLElementsCollectorWriter(newHTMLElementsCollector())
for i := 0; i < b.N; i++ {
fmt.Fprint(w, benchHTML)
}
}