(b *testing.B)
| 1557 | } |
| 1558 | |
| 1559 | func BenchmarkMapSessionDelta(b *testing.B) { |
| 1560 | for _, size := range []int{10, 100, 1_000, 10_000} { |
| 1561 | b.Run(fmt.Sprintf("size_%d", size), func(b *testing.B) { |
| 1562 | ctx := context.Background() |
| 1563 | nu := &countingNetmapUpdater{} |
| 1564 | ms := newTestMapSession(b, nu) |
| 1565 | // Disable log output for benchmarks to avoid races |
| 1566 | ms.logf = func(string, ...any) {} |
| 1567 | res := &tailcfg.MapResponse{ |
| 1568 | Node: &tailcfg.Node{ |
| 1569 | ID: 1, |
| 1570 | Name: "foo.bar.ts.net.", |
| 1571 | }, |
| 1572 | } |
| 1573 | for i := range size { |
| 1574 | res.Peers = append(res.Peers, &tailcfg.Node{ |
| 1575 | ID: tailcfg.NodeID(i + 2), |
| 1576 | Name: fmt.Sprintf("peer%d.bar.ts.net.", i), |
| 1577 | HomeDERP: 10, |
| 1578 | Addresses: []netip.Prefix{netip.MustParsePrefix("100.100.2.3/32"), netip.MustParsePrefix("fd7a:115c:a1e0::123/128")}, |
| 1579 | AllowedIPs: []netip.Prefix{netip.MustParsePrefix("100.100.2.3/32"), netip.MustParsePrefix("fd7a:115c:a1e0::123/128")}, |
| 1580 | Endpoints: eps("192.168.1.2:345", "192.168.1.3:678"), |
| 1581 | Hostinfo: (&tailcfg.Hostinfo{ |
| 1582 | OS: "fooOS", |
| 1583 | Hostname: "MyHostname", |
| 1584 | Services: []tailcfg.Service{ |
| 1585 | {Proto: "peerapi4", Port: 1234}, |
| 1586 | {Proto: "peerapi6", Port: 1234}, |
| 1587 | {Proto: "peerapi-dns-proxy", Port: 1}, |
| 1588 | }, |
| 1589 | }).View(), |
| 1590 | LastSeen: new(time.Unix(int64(i), 0)), |
| 1591 | }) |
| 1592 | } |
| 1593 | ms.HandleNonKeepAliveMapResponse(ctx, res) |
| 1594 | |
| 1595 | b.ResetTimer() |
| 1596 | b.ReportAllocs() |
| 1597 | |
| 1598 | // Now for the core of the benchmark loop, just toggle |
| 1599 | // a single node's online status. |
| 1600 | for i := range b.N { |
| 1601 | if err := ms.HandleNonKeepAliveMapResponse(ctx, &tailcfg.MapResponse{ |
| 1602 | OnlineChange: map[tailcfg.NodeID]bool{ |
| 1603 | 2: i%2 == 0, |
| 1604 | }, |
| 1605 | }); err != nil { |
| 1606 | b.Fatal(err) |
| 1607 | } |
| 1608 | } |
| 1609 | }) |
| 1610 | } |
| 1611 | } |
| 1612 | |
| 1613 | // TestNetmapDisplayMessage checks that the various diff operations |
| 1614 | // (add/update/delete/clear) for [tailcfg.DisplayMessage] in a |
nothing calls this directly
no test coverage detected
searching dependent graphs…