Source file src/simd/archsimd/_gen/simdgen/cputime_unix.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build unix
     6  
     7  package main
     8  
     9  import (
    10  	"syscall"
    11  	"time"
    12  )
    13  
    14  // cpuTime returns the user and system CPU time used by this process.
    15  func cpuTime() (time.Duration, bool) {
    16  	var ru syscall.Rusage
    17  	if err := syscall.Getrusage(syscall.RUSAGE_SELF, &ru); err != nil {
    18  		return 0, false
    19  	}
    20  	return time.Duration(ru.Utime.Nano() + ru.Stime.Nano()), true
    21  }
    22  

View as plain text