Benchmark the runDiff method
(b *testing.B)
| 616 | |
| 617 | // Benchmark the runDiff method |
| 618 | func 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 | } |
nothing calls this directly
no test coverage detected