MCPcopy
hub / github.com/bettercap/bettercap / BenchmarkRunDiff

Function BenchmarkRunDiff

modules/net_recon/net_recon_test.go:618–644  ·  view source on GitHub ↗

Benchmark the runDiff method

(b *testing.B)

Source from the content-addressed store, hash-verified

616
617// Benchmark the runDiff method
618func BenchmarkRunDiff(b *testing.B) {
619 sess := createMockSession()
620 aliases, _ := data.NewUnsortedKV("", 0)
621 sess.Lan = network.NewLAN(sess.Interface, sess.Gateway, aliases, func(e *network.Endpoint) {}, func(e *network.Endpoint) {})
622
623 mod := &Discovery{
624 SessionModule: session.NewSessionModule("net.recon", sess),
625 }
626
627 // Create a large ARP table
628 arpTable := make(network.ArpTable)
629 for i := 0; i < 100; i++ {
630 ip := fmt.Sprintf("192.168.1.%d", i)
631 mac := fmt.Sprintf("aa:bb:cc:dd:%02x:%02x", i/256, i%256)
632 arpTable[ip] = mac
633
634 // Add half to the existing LAN
635 if i < 50 {
636 sess.Lan.AddIfNew(ip, mac)
637 }
638 }
639
640 b.ResetTimer()
641 for i := 0; i < b.N; i++ {
642 mod.runDiff(arpTable)
643 }
644}

Callers

nothing calls this directly

Calls 5

runDiffMethod · 0.95
NewLANFunction · 0.92
NewSessionModuleFunction · 0.92
createMockSessionFunction · 0.70
AddIfNewMethod · 0.45

Tested by

no test coverage detected