]> Cypherpunks repositories - gostls13.git/commit
log: Prevent getting time if it's unnecessary
authorAlbert Nigmatzianov <albertnigma@gmail.com>
Mon, 22 May 2017 19:39:38 +0000 (21:39 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 22 May 2017 21:59:34 +0000 (21:59 +0000)
commit4cf19fb5a73a33f838efe21b3baa14167469ac83
tree755f51a56263f401d2e7c28868d39a9f33241b95
parentd433de6e86ce08e1b33e5d604080d3f504529006
log: Prevent getting time if it's unnecessary

Small performance gain:
name              old time/op    new time/op    delta
Itoa-4              95.4ns ± 4%    95.6ns ± 3%    ~     (p=0.256 n=45+46)
Println-4            480ns ± 4%     476ns ± 5%  -0.87%  (p=0.003 n=45+45)
PrintlnNoFlags-4     316ns ± 3%     299ns ± 4%  -5.38%  (p=0.000 n=42+44)

name              old alloc/op   new alloc/op   delta
Itoa-4               0.00B          0.00B         ~     (all equal)
Println-4            21.0B ± 0%     21.0B ± 0%    ~     (all equal)
PrintlnNoFlags-4     21.0B ± 0%     21.0B ± 0%    ~     (all equal)

name              old allocs/op  new allocs/op  delta
Itoa-4                0.00           0.00         ~     (all equal)
Println-4             2.00 ± 0%      2.00 ± 0%    ~     (all equal)
PrintlnNoFlags-4      2.00 ± 0%      2.00 ± 0%    ~     (all equal)

Change-Id: Idcd03609a5a437a69ffa7004a673bf0b8d22e7ad
Reviewed-on: https://go-review.googlesource.com/38056
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
src/log/log.go
src/log/log_test.go