github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/agent/ebpfspy/symtab/bcc_test.go (about) 1 //go:build ebpfspy 2 3 package symtab 4 5 import ( 6 "os" 7 "strings" 8 "testing" 9 ) 10 11 func TestGoSymBccFallback(t *testing.T) { 12 bcc := func() SymbolTable { 13 return NewBCCSymbolTable(os.Getpid()) 14 } 15 gosym, _ := NewGoSymbolTable("/proc/self/exe", &bcc) 16 malloc := testHelperGetMalloc() 17 res := gosym.Resolve(uint64(malloc), false) 18 if !strings.Contains(res.Name, "malloc") { 19 t.FailNow() 20 } 21 if !strings.Contains(res.Module, "libc.so") { 22 t.FailNow() 23 } 24 } 25 func BenchmarkBCC(b *testing.B) { 26 gosym, _ := NewGoSymbolTable("/proc/self/exe", nil) 27 bccsym := NewBCCSymbolTable(os.Getpid()) 28 if len(gosym.tab.symbols) < 1000 { 29 b.FailNow() 30 } 31 b.ResetTimer() 32 for i := 0; i < b.N; i++ { 33 for _, symbol := range gosym.tab.symbols { 34 bccsym.Resolve(symbol.Entry, false) 35 } 36 } 37 }