]> Cypherpunks repositories - gostls13.git/commit
time: optimize Format for RFC3339 and RFC3339Nano
authorAmarjeet Anand <amarjeetanandsingh@gmail.com>
Sun, 7 Aug 2022 18:19:19 +0000 (23:49 +0530)
committerGopher Robot <gobot@golang.org>
Thu, 11 Aug 2022 17:14:08 +0000 (17:14 +0000)
commit133c0e9011b8c0e13442cdb754d7f6a8ac54ce00
treed04b26c48313385e6d9d78711c44c6516d34394f
parent8298c545f384a6256962cb699f0c78306380279e
time: optimize Format for RFC3339 and RFC3339Nano

Optimise Format for the most frequently used RFC3339
and RFC3339Nano layouts by avoiding parsing of layout.

> benchstat oldBench.txt newBench.txt
name                 old time/op    new time/op    delta
FormatRFC3339-8         302ns ± 1%     203ns ± 0%  -32.89%  (p=0.016 n=5+4)
FormatRFC3339Nano-8     337ns ± 1%     219ns ± 1%  -34.91%  (p=0.008 n=5+5)

name                 old alloc/op   new alloc/op   delta
FormatRFC3339-8         32.0B ± 0%     32.0B ± 0%     ~     (all equal)
FormatRFC3339Nano-8     32.0B ± 0%     32.0B ± 0%     ~     (all equal)

name                 old allocs/op  new allocs/op  delta
FormatRFC3339-8          1.00 ± 0%      1.00 ± 0%     ~     (all equal)
FormatRFC3339Nano-8      1.00 ± 0%      1.00 ± 0%     ~     (all equal)

Fixes #54093

Change-Id: Ifc84fce6078e24514ecbcd234875bca4aaab5e0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/421877
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
src/time/format.go
src/time/time_test.go