Skip to content

Commit

Permalink
btf: add simple benchmark for parseLineInfoRecords
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Cacheux <paul.cacheux@datadoghq.com>
  • Loading branch information
paulcacheux authored and ti-mo committed Feb 5, 2025
1 parent 8462e8f commit b9d88ff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions btf/ext_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package btf

import (
"bytes"
"encoding/binary"
"strings"
"testing"

Expand All @@ -23,3 +24,16 @@ func TestParseExtInfoBigRecordSize(t *testing.T) {
t.Error("Parsing line info with large record size doesn't return an error")
}
}

func BenchmarkParseLineInfoRecords(b *testing.B) {
size := uint32(binary.Size(bpfLineInfo{}))
count := uint32(4096)
buf := make([]byte, size*count)

b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
parseLineInfoRecords(bytes.NewReader(buf), internal.NativeEndian, size, count, true)
}
}

0 comments on commit b9d88ff

Please # to comment.