Skip to content

Commit

Permalink
test(dockerlog): add ParseLog benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Aug 20, 2024
1 parent 84f765a commit 253c790
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/dockerlog/daemonlog_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package dockerlog

import (
"bytes"
"io"
"os"
"testing"

Expand Down Expand Up @@ -42,3 +44,29 @@ func TestParseLog(t *testing.T) {
}
require.NoError(t, iter.Err())
}

func BenchmarkParseLog(b *testing.B) {
data, err := os.ReadFile("_testdata/dockerlog.bin")
require.NoError(b, err)

var (
rd = bytes.NewReader(data)
rc = io.NopCloser(rd)

attrs = otelstorage.Attrs(pcommon.NewMap())
e logqlengine.Entry
)

b.SetBytes(int64(len(data)))
b.ResetTimer()

for i := 0; i < b.N; i++ {
rd.Reset(data)

iter := ParseLog(rc, attrs)
for iter.Next(&e) {
continue
}
iter.Close()
}
}

0 comments on commit 253c790

Please sign in to comment.