File: profiler_windows.go

package info (click to toggle)
golang-github-getsentry-sentry-go 0.29.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,404 kB
  • sloc: makefile: 75; sh: 21
file content (24 lines) | stat: -rw-r--r-- 536 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package sentry

import (
	"sync"
	"syscall"
)

// This works around the ticker resolution on Windows being ~15ms by default.
// See https://github.com/golang/go/issues/44343
func setTimeTickerResolution() {
	var winmmDLL = syscall.NewLazyDLL("winmm.dll")
	if winmmDLL != nil {
		var timeBeginPeriod = winmmDLL.NewProc("timeBeginPeriod")
		if timeBeginPeriod != nil {
			timeBeginPeriod.Call(uintptr(1))
		}
	}
}

var setupTickerResolutionOnce sync.Once

func onProfilerStart() {
	setupTickerResolutionOnce.Do(setTimeTickerResolution)
}