Answer the question
In order to leave comments, you need to log in
How to write a benchmark for a function in Golang?
I have a function that processes a packet, I wrote such a benchmark for it
func BenchmarkAccept(b *testing.B) {
q, _ := netfilter.NewNFQueue(1,1024,netfilter.NF_DEFAULT_PACKET_SIZE)
defer q.Close()
b.ResetTimer()
for i := 0; i < b.N; i++ {
p := <- q.GetPackets()
Accept(p)
}
}
BenchmarkAccept-4 1 4751730622 ns/op
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question