Add encode benchmarks

This commit is contained in:
2024-07-30 22:14:19 +02:00
parent 76d7102e72
commit 9fbcdd86cc
2 changed files with 44 additions and 11 deletions

View File

@@ -217,4 +217,38 @@ func TestDeletesLastValue(t *testing.T) {
if !bytes.Equal(data, expected) {
t.Errorf("expected %v, got %v", expected, data)
}
}
// benchmark
func BenchmarkGSM7EncodeSimpleASCIIString(b *testing.B) {
coder := &GSM7Coder{}
var buf bytes.Buffer
input := "Sunshine"
b.ResetTimer()
for i := 0; i < b.N; i++ {
coder.Encode(input, &buf)
}
}
func BenchmarkGSM7EncodeComplexASCIIString(b *testing.B) {
coder := &GSM7Coder{}
var buf bytes.Buffer
input := "Golden rays play, Chasing night away."
b.ResetTimer()
for i := 0; i < b.N; i++ {
coder.Encode(input, &buf)
}
}
func BenchmarkGSM7EncodeComplex8nASCIIString(b *testing.B) {
coder := &GSM7Coder{}
var buf bytes.Buffer
input := "Ducks are fucking great, they quacks, O quackers, what the fuck."
b.ResetTimer()
for i := 0; i < b.N; i++ {
coder.Encode(input, &buf)
}
}