Skip to content

Conversation

@lmittmann
Copy link
Owner

@lmittmann lmittmann commented May 26, 2025

This PR fixes an inconsistency in how time values are formatted. tint is meant to match the behavior of slog.TextHandler for log attributes beyond the standard attributes (slog.TimeKey...).

Performance Improvement

                                      │    v1.1.0    │                 pr                  │
                                      │    sec/op    │   sec/op     vs base                │
LogAttrs/h=tint/5_args-8                1282.0n ± 1%   949.0n ± 1%  -25.97% (p=0.000 n=10)
LogAttrs/h=tint/5_args_custom_level-8   1292.0n ± 2%   962.0n ± 1%  -25.54% (p=0.000 n=10)
LogAttrs/h=tint/10_args-8                2.293µ ± 2%   1.628µ ± 2%  -28.99% (p=0.000 n=10)
LogAttrs/h=tint/40_args-8                7.845µ ± 2%   5.035µ ± 2%  -35.82% (p=0.000 n=10)
LogAttrs/h=tint/error-8                  592.2n ± 1%   590.1n ± 2%        ~ (p=0.896 n=10)
LogAttrs/h=tint/attr-8                   536.9n ± 1%   537.9n ± 2%        ~ (p=0.542 n=10)
geomean                                  1.455µ        1.155µ       -20.59%

                                      │    v1.1.0    │                   pr                   │
                                      │     B/op     │     B/op      vs base                  │
LogAttrs/h=tint/5_args-8                 84.000 ± 0%     4.000 ± 0%  -95.24% (p=0.000 n=10)
LogAttrs/h=tint/5_args_custom_level-8    84.000 ± 0%     4.000 ± 0%  -95.24% (p=0.000 n=10)
LogAttrs/h=tint/10_args-8                 376.0 ± 0%     216.0 ± 0%  -42.55% (p=0.000 n=10)
LogAttrs/h=tint/40_args-8               2.032Ki ± 0%   1.407Ki ± 0%  -30.75% (p=0.000 n=10)
LogAttrs/h=tint/error-8                   36.00 ± 0%     36.00 ± 0%        ~ (p=1.000 n=10) ¹
LogAttrs/h=tint/attr-8                    32.00 ± 0%     32.00 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                   136.1          42.31       -68.92%
¹ all samples are equal

                                      │   v1.1.0    │                  pr                  │
                                      │  allocs/op  │ allocs/op   vs base                  │
LogAttrs/h=tint/5_args-8                 3.000 ± 0%   1.000 ± 0%  -66.67% (p=0.000 n=10)
LogAttrs/h=tint/5_args_custom_level-8    3.000 ± 0%   1.000 ± 0%  -66.67% (p=0.000 n=10)
LogAttrs/h=tint/10_args-8                7.000 ± 0%   3.000 ± 0%  -57.14% (p=0.000 n=10)
LogAttrs/h=tint/40_args-8               25.000 ± 0%   9.000 ± 0%  -64.00% (p=0.000 n=10)
LogAttrs/h=tint/error-8                  2.000 ± 0%   2.000 ± 0%        ~ (p=1.000 n=10) ¹
LogAttrs/h=tint/attr-8                   1.000 ± 0%   1.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                  3.829        1.944       -49.22%

@lmittmann lmittmann changed the title Fix time attribute formating to match slog.TextHandler Fix time attribute formatting to match slog.TextHandler May 26, 2025
@lmittmann lmittmann merged commit de5e6b7 into main May 26, 2025
2 checks passed
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