diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2022-12-31 12:03:51 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-05 19:48:17 -0700 |
commit | b1a69c59fdfbdb43de7f8ab949cfed19fcef6387 (patch) | |
tree | 6c2812ae93ef5df4b1b2f70cd8b07d6d341062de /lib/textui | |
parent | 3c3ec3e4ebb93b8e09a5a93bd26ace84f271223e (diff) |
textui: Add doc comments for LiveMemUse
Diffstat (limited to 'lib/textui')
-rw-r--r-- | lib/textui/log_memstats.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/textui/log_memstats.go b/lib/textui/log_memstats.go index 7ef35da..31d526f 100644 --- a/lib/textui/log_memstats.go +++ b/lib/textui/log_memstats.go @@ -11,6 +11,13 @@ import ( "time" ) +// LiveMemUse is an object that stringifies as the live memory use of +// the program. +// +// It is intended to be used with dlog by attaching it as a field, so +// that all log lines include the current memory use: +// +// ctx = dlog.WithField(ctx, "mem", new(textui.LiveMemUse)) type LiveMemUse struct { mu sync.Mutex stats runtime.MemStats @@ -19,8 +26,13 @@ type LiveMemUse struct { var _ fmt.Stringer = (*LiveMemUse)(nil) +// LiveMemUseUpdateInterval is the shortest interval on which +// LiveMemUse is willing to update; we have this minimum interval +// because it stops the world to collect memory statistics, so we +// don't want to be updating the statistics too often. var LiveMemUseUpdateInterval = Tunable(1 * time.Second) +// String implements fmt.Stringer. func (o *LiveMemUse) String() string { o.mu.Lock() |