github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/oslib/clock.go (about) 1 //go:build !windows 2 // +build !windows 3 4 package oslib 5 6 import ( 7 "syscall" 8 9 rt "github.com/arnodel/golua/runtime" 10 ) 11 12 func clock(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { 13 var rusage syscall.Rusage 14 _ = syscall.Getrusage(syscall.RUSAGE_SELF, &rusage) // ignore errors 15 time := float64(rusage.Utime.Sec+rusage.Stime.Sec) + float64(rusage.Utime.Usec+rusage.Stime.Usec)/1000000.0 16 return c.PushingNext1(t.Runtime, rt.FloatValue(time)), nil 17 }