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
+30 -12
View File
@@ -58,21 +58,10 @@ func TestGoodKvGet(t *testing.T) {
expected any
}{
{
name: "basic value",
name: "basic key",
params: map[string]any{
"module": "test",
"key": "test",
"value": "hello",
},
payload: "hello",
expected: "test",
},
{
name: "template value",
params: map[string]any{
"module": "test",
"key": "test",
"value": "{{.Payload}}",
},
payload: "hello",
expected: "test",
@@ -232,3 +221,32 @@ func TestBadKvGet(t *testing.T) {
})
}
}
func BenchmarkKvGet(b *testing.B) {
registration, ok := processor.ProcessorRegistry["kv.get"]
if !ok {
b.Fatalf("kv.get processor not registered")
}
processorInstance, err := registration.New(config.ProcessorConfig{
Type: "kv.get",
Params: map[string]any{
"module": "test",
"key": "test",
},
})
if err != nil {
b.Fatalf("kv.get failed to create processor: %s", err)
}
modules := map[string]common.Module{
"test": test.NewTestKVModule("test"),
}
for b.Loop() {
_, err := processorInstance.Process(b.Context(), common.WrappedPayload{Payload: nil, Modules: modules})
if err != nil {
b.Fatalf("kv.get processing failed: %s", err)
}
}
}