ebpfbench

package module
v0.0.0-...-14eabe1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

README

ebpfbench

profile eBPF programs from Go. Requires Linux kernel 5.1 or greater.

Usage

ebpfbench augments the standard testing.B object.

func BenchmarkExample(b *testing.B) {
    eb := ebpfbench.NewEBPFBenchmark(b)
    defer eb.Close()
    
    // setup eBPF programs using cilium/ebpf, gobpf, or other libraries.
    
    fd := prog.FD()
    eb.ProfileProgram(fd, "")
    eb.Run(func(b *testing.B) {
        // exercise programs here
    })
}

The results per program will be output in the standard go benchmark format.

goos: linux
goarch: amd64
pkg: github.com/DataDog/bench-example
BenchmarkExample/eBPF-4         	                   66741	     20344 ns/op
BenchmarkExample/eBPF/kprobe/sys_bind           	       1	       568 ns/op
BenchmarkExample/eBPF/kprobe/sys_socket         	       3	      1110 ns/op
BenchmarkExample/eBPF/kprobe/tcp_cleanup_rbuf   	  266952	       295 ns/op

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWrappedFD

func NewWrappedFD(raw int) *wrappedFD

Types

type EBPFBenchmark

type EBPFBenchmark struct {
	// contains filtered or unexported fields
}

func NewEBPFBenchmark

func NewEBPFBenchmark(b *testing.B) *EBPFBenchmark

func (*EBPFBenchmark) Close

func (e *EBPFBenchmark) Close()

func (*EBPFBenchmark) ProfileProgram

func (e *EBPFBenchmark) ProfileProgram(fd int, name string)

func (*EBPFBenchmark) Run

func (e *EBPFBenchmark) Run(fn func(*testing.B))

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL