aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/os_windows.go
diff options
context:
space:
mode:
authorJordan Rhee <jordanrh@microsoft.com>2018-12-18 12:54:23 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2018-12-18 23:01:06 +0000
commite3b4b7baad555f74b6fbc0ddc00d46ed0ac03a0a (patch)
tree9b67e4b0bd73d150289a8e5decaae8b56fc78e1f /src/runtime/os_windows.go
parent9ded8b0e97588895e00e93299e4a4a748cfa3a4b (diff)
downloadgo1.12beta1.tar.xz
runtime: use QPC for nanotime and time.now on windows/armgo1.12beta1
The previous implementation of nanotime and time.now used a time source that was updated on the system clock tick, which has a maximum resolution of about 1ms. On 386 and amd64, this time source maps to the system performance counter, so has much higher resolution. On ARM, use QueryPerformanceCounter() to get a high resolution timestamp. Updates #26148 Change-Id: I1abc99baf927a95b472ac05020a7788626c71d08 Reviewed-on: https://go-review.googlesource.com/c/154758 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/os_windows.go')
-rw-r--r--src/runtime/os_windows.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go
index 9b34589874..20fe01c403 100644
--- a/src/runtime/os_windows.go
+++ b/src/runtime/os_windows.go
@@ -198,9 +198,12 @@ func loadOptionalSyscalls() {
}
_NtWaitForSingleObject = windowsFindfunc(n32, []byte("NtWaitForSingleObject\000"))
- if windowsFindfunc(n32, []byte("wine_get_version\000")) != nil {
- // running on Wine
- initWine(k32)
+ underWine := windowsFindfunc(n32, []byte("wine_get_version\000")) != nil
+ if underWine || GOARCH == "arm" {
+ initQPC(k32)
+ }
+ if underWine {
+ initWine()
}
}
@@ -357,7 +360,7 @@ func nowQPC() (sec int64, nsec int32, mono int64) {
return
}
-func initWine(k32 uintptr) {
+func initQPC(k32 uintptr) {
_GetSystemTimeAsFileTime = windowsFindfunc(k32, []byte("GetSystemTimeAsFileTime\000"))
if _GetSystemTimeAsFileTime == nil {
throw("could not find GetSystemTimeAsFileTime() syscall")
@@ -394,7 +397,9 @@ func initWine(k32 uintptr) {
// We have to do it this way (or similar), since multiplying QPC counter by 100 millions overflows
// int64 and resulted time will always be invalid.
qpcMultiplier = int64(timediv(1000000000, qpcFrequency, nil))
+}
+func initWine() {
useQPCTime = 1
}