add basic benchmark for most processors

This commit is contained in:
Joel Wetzell
2026-05-14 19:44:19 -05:00
parent fa4997ba78
commit 9eb05c8360
43 changed files with 1085 additions and 12 deletions
+26
View File
@@ -1,6 +1,7 @@
package processor_test
import (
"fmt"
"testing"
"github.com/jwetzell/showbridge-go/internal/common"
@@ -198,3 +199,28 @@ func TestBadIntParse(t *testing.T) {
})
}
}
func BenchmarkIntParse(b *testing.B) {
registration, ok := processor.ProcessorRegistry["int.parse"]
if !ok {
b.Fatalf("int.parse processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "int.parse",
Params: nil,
})
if err != nil {
b.Fatalf("int.parse failed to create processor: %s", err)
}
count := 0
for b.Loop() {
_, err := processorInstance.Process(b.Context(), common.WrappedPayload{Payload: fmt.Sprintf("%d", count)})
if err != nil {
b.Fatalf("int.parse processing failed: %s", err)
}
count++
}
}