diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-05-11 15:35:35 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-05-11 16:03:06 +0200 |
commit | 27e1ef9a420e42a30b8194ea39d7952b4c93d5c4 (patch) | |
tree | f3c100802ab28da242822d23e998f4acbd44e307 | |
parent | 386e4198d8459803eec0ead6ad81a821737082a7 (diff) |
Benchmark more combinations
-rw-r--r-- | client/go/internal/vespa/document/document.go | 4 | ||||
-rw-r--r-- | client/go/internal/vespa/document/http_test.go | 23 |
2 files changed, 18 insertions, 9 deletions
diff --git a/client/go/internal/vespa/document/document.go b/client/go/internal/vespa/document/document.go index 89127d82dce..ce8b22b24f0 100644 --- a/client/go/internal/vespa/document/document.go +++ b/client/go/internal/vespa/document/document.go @@ -265,7 +265,7 @@ func NewGenerator(size int, deadline time.Time) *Generator { return &Generator{Size: size, Deadline: deadline, nowFunc: time.Now} } -func (g *Generator) randString(size int) string { +func randString(size int) string { b := make([]byte, size) for i := range b { b[i] = byte('a' + rand.Intn('z'-'a'+1)) @@ -278,7 +278,7 @@ func (g *Generator) Read(p []byte) (int, error) { if !g.nowFunc().Before(g.Deadline) { return 0, io.EOF } - fmt.Fprintf(&g.buf, "{\"put\": \"id:test:test::%s\", \"fields\": {\"test\": \"%s\"}}\n", g.randString(8), g.randString(g.Size)) + fmt.Fprintf(&g.buf, "{\"put\": \"id:test:test::%s\", \"fields\": {\"test\": \"%s\"}}\n", randString(8), randString(g.Size)) } return g.buf.Read(p) } diff --git a/client/go/internal/vespa/document/http_test.go b/client/go/internal/vespa/document/http_test.go index 9a47b4f45fe..8fb0b1b2b95 100644 --- a/client/go/internal/vespa/document/http_test.go +++ b/client/go/internal/vespa/document/http_test.go @@ -288,13 +288,22 @@ func benchmarkClientSend(b *testing.B, compression Compression, document Documen } } -func BenchmarkClientSend(b *testing.B) { - doc := Document{Create: true, Id: mustParseId("id:ns:type::doc1"), Operation: OperationUpdate, Fields: []byte(`{"foo": "my document"}`)} - benchmarkClientSend(b, CompressionNone, doc) +func makeDocument(size int) Document { + return Document{Id: mustParseId("id:ns:type::doc1"), Operation: OperationUpdate, Fields: []byte(fmt.Sprintf(`{"foo": "%s"}`, randString(size)))} } -func BenchmarkClientSendCompressed(b *testing.B) { - body := fmt.Sprintf(`{"foo": "%s"}`, strings.Repeat("my document", 100)) - doc := Document{Create: true, Id: mustParseId("id:ns:type::doc1"), Operation: OperationUpdate, Fields: []byte(body)} - benchmarkClientSend(b, CompressionGzip, doc) +func BenchmarkClientSendSmallUncompressed(b *testing.B) { + benchmarkClientSend(b, CompressionNone, makeDocument(10)) +} + +func BenchmarkClientSendMediumUncompressed(b *testing.B) { + benchmarkClientSend(b, CompressionNone, makeDocument(10)) +} + +func BenchmarkClientSendMediumGzip(b *testing.B) { + benchmarkClientSend(b, CompressionGzip, makeDocument(1000)) +} + +func BenchmarkClientSendLargeGzip(b *testing.B) { + benchmarkClientSend(b, CompressionGzip, makeDocument(10000)) } |