added check for CLK_TCK

pull/869/head
renaynay 5 years ago
parent 987c949880
commit d4985c9690
No known key found for this signature in database
GPG Key ID: 6557F5413D663EDB

@ -4,6 +4,7 @@ package cpu
import (
"context"
"os/exec"
"strconv"
"strings"
@ -23,6 +24,21 @@ const (
// default value. from time.h
var ClocksPerSec = float64(128)
func init() {
getconf, err := exec.LookPath("getconf")
if err != nil {
return
}
out, err := invoke.Command(getconf, "CLK_TCK")
// ignore errors
if err == nil {
i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
if err == nil {
ClocksPerSec = float64(i)
}
}
}
func Times(percpu bool) ([]TimesStat, error) {
return TimesWithContext(context.Background(), percpu)
}

Loading…
Cancel
Save