7a04f298d2
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
35 lines
1011 B
Go
35 lines
1011 B
Go
package html
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message/entity"
|
|
)
|
|
|
|
func BenchmarkHTML(b *testing.B) {
|
|
input := `<b>bold</b>, <strong>bold</strong>
|
|
<i>italic</i>, <em>italic</em>
|
|
<u>underline</u>, <ins>underline</ins>
|
|
<s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
|
|
<b>bold <i>italic bold <s>italic bold strikethrough</s> <u>underline italic bold</u></i> bold</b>
|
|
<a href="http://www.example.com/">inline URL</a>
|
|
<a href="tg://user?id=123456789">inline mention of a user</a>
|
|
<code>inline fixed-width code</code>
|
|
<pre>pre-formatted fixed-width code block</pre>
|
|
<pre><code class="language-python">pre-formatted fixed-width code block written in the Python programming language</code></pre>`
|
|
reader := strings.NewReader(input)
|
|
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
reader.Reset(input)
|
|
builder := entity.Builder{}
|
|
|
|
if err := HTML(reader, &builder, Options{}); err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
}
|