go/src/time
Russ Cox e4371fb179 time: optimize Now on darwin, windows
Fetch both monotonic and wall time together when possible.
Avoids skew and is cheaper.

Also shave a few ns off in conversion in package time.

Compared to current implementation (after monotonic changes):

name   old time/op  new time/op  delta
Now    19.6ns ± 1%   9.7ns ± 1%  -50.63%  (p=0.000 n=41+49) darwin/amd64
Now    23.5ns ± 4%  10.6ns ± 5%  -54.61%  (p=0.000 n=30+28) windows/amd64
Now    54.5ns ± 5%  29.8ns ± 9%  -45.40%  (p=0.000 n=27+29) windows/386

More importantly, compared to Go 1.8:

name   old time/op  new time/op  delta
Now     9.5ns ± 1%   9.7ns ± 1%   +1.94%  (p=0.000 n=41+49) darwin/amd64
Now    12.9ns ± 5%  10.6ns ± 5%  -17.73%  (p=0.000 n=30+28) windows/amd64
Now    15.3ns ± 5%  29.8ns ± 9%  +94.36%  (p=0.000 n=30+29) windows/386

This brings time.Now back in line with Go 1.8 on darwin/amd64 and windows/amd64.

It's not obvious why windows/386 is still noticeably worse than Go 1.8,
but it's better than before this CL. The windows/386 speed is not too
important; the changes just keep the two architectures similar.

Change-Id: If69b94970c8a1a57910a371ee91e0d4e82e46c5d
Reviewed-on: https://go-review.googlesource.com/36428
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-09 14:45:16 +00:00
..
example_test.go time: improve Truncate and Round documentation 2016-09-12 22:07:17 +00:00
export_android_test.go time: load time zones from the system tzdata file on Android 2016-08-23 06:15:35 +00:00
export_test.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
export_windows_test.go
format.go time: format negative monotonic times correctly in Time.String 2017-02-09 02:41:15 +00:00
format_test.go time: parse WITA timezone correctly 2016-12-12 20:14:12 +00:00
genzabbrs.go
internal_test.go
mono_test.go time: optimize Now on darwin, windows 2017-02-09 14:45:16 +00:00
sleep.go time: update Timer.Stop doc to account for AfterFunc 2016-11-11 19:25:24 +00:00
sleep_test.go
sys_plan9.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
sys_unix.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
sys_windows.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
tick.go
tick_test.go
time.go time: optimize Now on darwin, windows 2017-02-09 14:45:16 +00:00
time_test.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
zoneinfo.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
zoneinfo_abbrs_windows.go time: always use $GOROOT/lib/time/zoneinfo.zip with genzabbrs.go 2016-08-28 02:51:07 +00:00
zoneinfo_android.go time: load time zones from the system tzdata file on Android 2016-08-23 06:15:35 +00:00
zoneinfo_android_test.go time: load time zones from the system tzdata file on Android 2016-08-23 06:15:35 +00:00
zoneinfo_ios.go
zoneinfo_plan9.go time: record monotonic clock reading in time.Now, for more accurate comparisons 2017-02-03 19:04:52 +00:00
zoneinfo_read.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
zoneinfo_test.go time: bound file reads and validate LoadLocation argument 2017-02-08 16:20:25 +00:00
zoneinfo_unix.go time: load time zones from the system tzdata file on Android 2016-08-23 06:15:35 +00:00
zoneinfo_windows.go time: record monotonic clock reading in time.Now, for more accurate comparisons 2017-02-03 19:04:52 +00:00
zoneinfo_windows_test.go