move gotd fork into repo. (#111)
- 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
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package bin_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message/entity"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/telegram/message/styling"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/tg"
|
||||
)
|
||||
|
||||
func BenchmarkDecodeSlice(b *testing.B) {
|
||||
builder := entity.Builder{}
|
||||
if err := styling.Perform(&builder,
|
||||
styling.Plain("plaintext"), styling.Plain("\n\n"),
|
||||
styling.Mention("@durov"), styling.Plain("\n\n"),
|
||||
styling.Hashtag("#hashtag"), styling.Plain("\n\n"),
|
||||
styling.BotCommand("/command"), styling.Plain("\n\n"),
|
||||
styling.URL("https://google.org"), styling.Plain("\n\n"),
|
||||
styling.Email("example@example.org"), styling.Plain("\n\n"),
|
||||
styling.Bold("bold"), styling.Plain("\n\n"),
|
||||
styling.Italic("italic"), styling.Plain("\n\n"),
|
||||
styling.Underline("underline"), styling.Plain("\n\n"),
|
||||
styling.Strike("strike"), styling.Plain("\n\n"),
|
||||
styling.Code("fmt.Println(`Hello, World!`)"), styling.Plain("\n\n"),
|
||||
styling.Pre("fmt.Println(`Hello, World!`)", "Go"), styling.Plain("\n\n"),
|
||||
styling.TextURL("clickme", "https://google.com"), styling.Plain("\n\n"),
|
||||
styling.Phone("+71234567891"), styling.Plain("\n\n"),
|
||||
styling.Cashtag("$CASHTAG"), styling.Plain("\n\n"),
|
||||
styling.Blockquote("blockquote", false), styling.Plain("\n\n"),
|
||||
styling.BankCard("5550111111111111"), styling.Plain("\n\n"),
|
||||
); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
message, entities := builder.Complete()
|
||||
|
||||
var buf bin.Buffer
|
||||
if err := buf.Encode(&tg.Message{
|
||||
PeerID: &tg.PeerUser{},
|
||||
Message: message,
|
||||
Entities: entities,
|
||||
}); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
var msg tg.Message
|
||||
|
||||
if err := msg.Decode(&bin.Buffer{Buf: buf.Buf}); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user