github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/oslib/clock_windows.go (about) 1 //go:build windows 2 // +build windows 3 4 package oslib 5 6 import ( 7 "time" 8 9 rt "github.com/arnodel/golua/runtime" 10 ) 11 12 var startTime time.Time 13 14 func clock(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { 15 // No syscall.Getrusage on windows. As a fallback return clock time since 16 // starting the program. 17 time := float64(time.Now().Sub(startTime).Microseconds()) / 1e6 18 return c.PushingNext1(t.Runtime, rt.FloatValue(time)), nil 19 } 20 21 func init() { 22 startTime = time.Now() 23 }