github.com/ergo-services/ergo@v1.999.224/lib/osdep/linux.go (about)

     1  //go:build linux
     2  // +build linux
     3  
     4  package osdep
     5  
     6  import (
     7  	"syscall"
     8  )
     9  
    10  // ResourceUsage
    11  func ResourceUsage() (int64, int64) {
    12  	var usage syscall.Rusage
    13  	var utime, stime int64
    14  	if err := syscall.Getrusage(syscall.RUSAGE_SELF, &usage); err == nil {
    15  		utime = int64(usage.Utime.Sec)*1000000000 + usage.Utime.Nano()
    16  		stime = int64(usage.Stime.Sec)*1000000000 + usage.Stime.Nano()
    17  	}
    18  	return utime, stime
    19  }