mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
net/art: add debug hooks to strideTable
Updates #7781 Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
fcf4d044fa
commit
ac657caaf1
@ -13,6 +13,11 @@
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
debugStrideInsert = false
|
||||
debugStrideDelete = false
|
||||
)
|
||||
|
||||
// strideEntry is a strideTable entry.
|
||||
type strideEntry[T any] struct {
|
||||
// prefixIndex is the prefixIndex(...) value that caused this stride entry's
|
||||
|
@ -52,11 +52,15 @@ func TestStrideTableInsert(t *testing.T) {
|
||||
slow := slowTable[int]{pfxs}
|
||||
fast := strideTable[int]{}
|
||||
|
||||
t.Logf("slow table:\n%s", slow.String())
|
||||
if debugStrideInsert {
|
||||
t.Logf("slow table:\n%s", slow.String())
|
||||
}
|
||||
|
||||
for _, pfx := range pfxs {
|
||||
fast.insert(pfx.addr, pfx.len, pfx.val)
|
||||
t.Logf("after insert %d/%d:\n%s", pfx.addr, pfx.len, fast.tableDebugString())
|
||||
if debugStrideInsert {
|
||||
t.Logf("after insert %d/%d:\n%s", pfx.addr, pfx.len, fast.tableDebugString())
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 256; i++ {
|
||||
@ -122,11 +126,15 @@ func TestStrideTableDelete(t *testing.T) {
|
||||
slow := slowTable[int]{pfxs}
|
||||
fast := strideTable[int]{}
|
||||
|
||||
t.Logf("slow table:\n%s", slow.String())
|
||||
if debugStrideDelete {
|
||||
t.Logf("slow table:\n%s", slow.String())
|
||||
}
|
||||
|
||||
for _, pfx := range pfxs {
|
||||
fast.insert(pfx.addr, pfx.len, pfx.val)
|
||||
t.Logf("after insert %d/%d:\n%s", pfx.addr, pfx.len, fast.tableDebugString())
|
||||
if debugStrideDelete {
|
||||
t.Logf("after insert %d/%d:\n%s", pfx.addr, pfx.len, fast.tableDebugString())
|
||||
}
|
||||
}
|
||||
|
||||
toDelete := pfxs[:50]
|
||||
|
Loading…
Reference in New Issue
Block a user