mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
clock: Avoid calling (js.Value).Get() for performance
This commit is contained in:
parent
9bb96a4012
commit
7bb2895415
@ -21,10 +21,15 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
jsPerformance = js.Global().Get("performance")
|
||||
jsNow = jsPerformance.Get("now").Call("bind", jsPerformance)
|
||||
)
|
||||
|
||||
func now() int64 {
|
||||
// time.Now() is not reliable until GopherJS supports performance.now().
|
||||
//
|
||||
// performance.now is monotonic:
|
||||
// https://www.w3.org/TR/hr-time-2/#sec-monotonic-clock
|
||||
return int64(js.Global().Get("performance").Call("now").Float() * float64(time.Millisecond))
|
||||
return int64(jsNow.Invoke().Float() * float64(time.Millisecond))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user