testing.B.Loop() standardization and StackAsync.Debug improvement (#156)

* testing.B.Loop() standardization and StackAsync.Debug heap debugging improvement

* apply @MDr164 fixes

* @MDr164 great suggestions to prevent panic and print correct mallocs
This commit is contained in:
Pat Whittingslow
2026-07-17 11:59:27 -03:00
committed by GitHub
parent 766e03e90e
commit 157a8537a2
10 changed files with 64 additions and 45 deletions
+4 -10
View File
@@ -842,24 +842,18 @@ func addr4(addr [4]byte, ok bool) netip.Addr {
return netip.AddrFrom4(addr)
}
// Debug prints debugging information. Very useful for users when coupled with
// the debugheaplog build tag. See [internal.LogAttrs] debugheaplog version.
//
// go build -tags=debugheaplog ./yourprogram
// Debug prints debugging and heap information.
func (s *StackAsync) Debug(msg string) {
internal.LogAttrs(slog.Default(), slog.LevelDebug, "stackasync",
internal.LogAttrsAndAllocs(msg, slog.Default(), slog.LevelDebug, "stackasync",
slog.String("umsg", msg),
slog.Uint64("sent", s.stats.TotalSent),
slog.Uint64("recv", s.stats.TotalReceived),
)
}
// DebugErr prints debugging and error info. Very useful for users when coupled with
// the debugheaplog build tag. See [internal.LogAttrs] debugheaplog version.
//
// go build -tags=debugheaplog ./yourprogram
// DebugErr prints debugging and heap information.
func (s *StackAsync) DebugErr(msg, err string) {
internal.LogAttrs(slog.Default(), slog.LevelError, "stackasync",
internal.LogAttrsAndAllocs(msg, slog.Default(), slog.LevelError, "stackasync",
slog.String("umsg", msg),
slog.String("err", err),
slog.Uint64("sent", s.stats.TotalSent),