From ac657caaf16ada4f6cec957348ad64e2fb211917 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 13 Jul 2023 12:25:08 -0700 Subject: [PATCH] net/art: add debug hooks to strideTable Updates #7781 Signed-off-by: David Anderson --- net/art/stride_table.go | 5 +++++ net/art/stride_table_test.go | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/net/art/stride_table.go b/net/art/stride_table.go index 53ae958c5..2ceb4d043 100644 --- a/net/art/stride_table.go +++ b/net/art/stride_table.go @@ -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 diff --git a/net/art/stride_table_test.go b/net/art/stride_table_test.go index e706ad640..a974479a5 100644 --- a/net/art/stride_table_test.go +++ b/net/art/stride_table_test.go @@ -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]