Skip to content

Commit

Permalink
publisher: Add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Feb 5, 2023
1 parent 76c6140 commit 4f4a1c0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions publisher/htmlElementsCollector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
}

0 comments on commit 4f4a1c0

Please sign in to comment.