Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions decoder/cri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ func TestCRIJoined3Lines(t *testing.T) {
assert.Equal(t, `{"level":"warn","ts":"2024-05-22T06:39:29.230Z"}\n`, string(row.Log))
assert.Equal(t, false, row.IsPartial)
}

func BenchmarkDecodeCRI(b *testing.B) {
for b.Loop() {
_, _ = DecodeCRI([]byte("2016-10-06T00:17:09.669794202Z stdout P partial content 1\n"))
}
}
8 changes: 8 additions & 0 deletions decoder/csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,11 @@ func TestDecodeToJsonCSV(t *testing.T) {
})
}
}

func BenchmarkDecodeCSV(b *testing.B) {
d, _ := NewCSVDecoder(make(map[string]any))

for b.Loop() {
_, _ = d.Decode([]byte(`a,b,c`))
}
}
10 changes: 10 additions & 0 deletions decoder/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,13 @@ func TestNginxError(t *testing.T) {
})
}
}

func BenchmarkDecodeNginx(b *testing.B) {
const input = `2022/08/18 09:29:37 [error] 844935#844935: *44934601 upstream timed out (110: Operation timed out) while connecting to upstream, client: 10.125.172.251, server: mpm-youtube-downloader-38.name.tldn, request: "POST /download HTTP/1.1", upstream: "http://10.117.246.15:84/download", host: "mpm-youtube-downloader-38.name.tldn:84"` + "\n"

d, _ := NewNginxErrorDecoder(nil)

for b.Loop() {
_, _ = d.Decode([]byte(input))
}
}
6 changes: 6 additions & 0 deletions decoder/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ func TestPostgres(t *testing.T) {
assert.Equal(t, "test_user", root.Dig("user").AsString())
assert.Equal(t, "listening on Unix socket \"/var/run/postgresql/.s.PGSQL.5432\"\n", root.Dig("log").AsString())
}

func BenchmarkDecodePostgres(b *testing.B) {
for b.Loop() {
_, _ = DecodePostgres([]byte("2021-06-22 16:24:27 GMT [7291] => [3-1] client=test_client,db=test_db,user=test_user LOG: listening on Unix socket \"/var/run/postgresql/.s.PGSQL.5432\"\n"))
}
}
20 changes: 20 additions & 0 deletions decoder/protobuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,23 @@ func TestProtobuf(t *testing.T) {
})
}
}

func BenchmarkDecodeProtobuf(b *testing.B) {
const protoMessage = "MyMessage"

inputData := []byte{10, 13, 10, 9, 109, 121, 95, 115, 116, 114, 105, 110, 103, 16, 123, 18, 14, 10, 4, 115, 116, 114, 49, 10, 4, 115, 116, 114, 50, 16, 1, 24, 10}

p := map[string]any{
protoFileParam: "with_imports.proto",
protoMessageParam: protoMessage,
protoImportPathsParam: []any{
"../testdata/proto",
},
}

dec, _ := NewProtobufDecoder(p)

for b.Loop() {
_, _ = dec.Decode(inputData)
}
}
10 changes: 10 additions & 0 deletions decoder/syslog_rfc3164_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,13 @@ func TestSyslogRFC3164(t *testing.T) {
})
}
}

func BenchmarkDecodeSyslogRFC3164(b *testing.B) {
const input = "<34>Oct 11 22:14:15 mymachine.example.com myproc[10]: 'myproc' failed on /dev/pts/8\n"

d, _ := NewSyslogRFC3164Decoder(nil)

for b.Loop() {
_, _ = d.Decode([]byte(input))
}
}
10 changes: 10 additions & 0 deletions decoder/syslog_rfc5424_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,13 @@ func TestSyslogRFC5424(t *testing.T) {
})
}
}

func BenchmarkDecodeSyslogRFC5424(b *testing.B) {
const input = "<165>1 2003-10-11T22:14:15.003Z mymachine.example.com myproc 10 ID47 [exampleSDID@32473 iut=\"3\" eventSource=\"My \\\"Application\\\"\" eventID=\"1011\"] An application event log\n"

d, _ := NewSyslogRFC5424Decoder(nil)

for b.Loop() {
_, _ = d.Decode([]byte(input))
}
}