test: add benchmarks for various components
Adds benchmarking tests to ensure the application remains low on resources. Covers payload parsing, auth verification, IRC chat line formatting, and more.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package tui
|
||||
|
||||
import "testing"
|
||||
import "parasocial/internal/twitch"
|
||||
|
||||
func BenchmarkFormatIRCChatLine(b *testing.B) {
|
||||
line := ":jules!jules@jules.tmi.twitch.tv PRIVMSG #parasocial :Hello world this is a test message"
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, _ = formatIRCChatLine(line)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkNormalizeKey(b *testing.B) {
|
||||
key := "SomeStreamerName"
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = normalizeKey(key)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIsActive(b *testing.B) {
|
||||
entry := twitch.StreamerEntry{Status: twitch.StreamerReady}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
_ = isActive(entry)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user