Skip to content

Avoid throwaway time rounding - #102

Merged
lmittmann merged 1 commit into
lmittmann:mainfrom
scop:perf/throwaway-time-round
Feb 9, 2026
Merged

lmittmann merged 1 commit into
lmittmann:mainfrom
scop:perf/throwaway-time-round

Conversation

@scop

@scop scop commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@lmittmann

Copy link
Copy Markdown
Owner

Thanks for raising this. I am not really sure, if rounding should be done if ReplaceAttr is NOT present. log/slog does rounding for both cases (https://github.com/golang/go/blob/master/src/log/slog/handler.go#L281-L290):

if !r.Time.IsZero() {
	key := TimeKey
	val := r.Time.Round(0) // strip monotonic to match Attr behavior
	if rep == nil {
		state.appendKey(key)
		state.appendTime(val)
	} else {
		state.appendAttr(Time(key, val))
	}
}

@scop

scop commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

Yeah, it's not throwaway if tint changes to do the rounding in both code branches. (I haven't examined what that would entail.)

@lmittmann
lmittmann merged commit dcba16d into lmittmann:main Feb 9, 2026
2 checks passed
@scop
scop deleted the perf/throwaway-time-round branch February 9, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants