diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-04-19 17:54:17 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-04-19 17:55:05 +0200 |
commit | 050fefd2a825909e82312934a50d85e1e51c857a (patch) | |
tree | 15d3e640e0f97253f399adb6023f349cd767904d /client/go | |
parent | 7a399e0b79375594eede5281f9ece22e2e78715b (diff) |
Add dispatch benchmark
Diffstat (limited to 'client/go')
-rw-r--r-- | client/go/internal/vespa/document/dispatcher_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/client/go/internal/vespa/document/dispatcher_test.go b/client/go/internal/vespa/document/dispatcher_test.go index d066f5bc9ae..c8f8e550ba4 100644 --- a/client/go/internal/vespa/document/dispatcher_test.go +++ b/client/go/internal/vespa/document/dispatcher_test.go @@ -130,3 +130,18 @@ func TestDispatcherOrderingWithFailures(t *testing.T) { assert.Equal(t, int64(2), dispatcher.Stats().Errors) assert.Equal(t, 6, len(feeder.documents)) } + +func BenchmarkDocumentDispatching(b *testing.B) { + feeder := &mockFeeder{} + clock := &manualClock{tick: time.Second} + throttler := newThrottler(8, clock.now) + breaker := NewCircuitBreaker(time.Second, 0) + dispatcher := NewDispatcher(feeder, throttler, breaker, io.Discard, false) + doc := Document{Id: mustParseId("id:ns:type::doc1"), Operation: OperationPut, Body: []byte(`{"fields":{"foo": "123"}}`)} + b.ResetTimer() // ignore setup time + + for n := 0; n < b.N; n++ { + dispatcher.enqueue(documentOp{document: doc}) + dispatcher.workerWg.Wait() + } +} |