commit | e0a236ac1fd1f797c7796eaa48fd29220d947c03 | [log] [tgz] |
---|---|---|
author | Seth Hoenig <shoenig@duck.com> | Thu Mar 23 07:14:03 2023 -0500 |
committer | Seth Hoenig <shoenig@duck.com> | Thu Mar 23 07:14:03 2023 -0500 |
tree | ade33653066afc2671ce0caabc3b496211049124 | |
parent | 76bc9f98fc5c741d7adc212b0d33f8bf32359a65 [diff] |
m1cpu: able to read p-core and e-core counts
The go-m1cpu
module is a library for inspecting Apple Silicon CPUs in Go.
Use the m1cpu
library for looking up the CPU frequency for Apple M1 and M2 CPUs.
go get github.com/shoenig/go-m1cpu@latest
package main
import (
"fmt"
"github.com/shoenig/go-m1cpu"
)
func main() {
fmt.Println("Apple Silicon", m1cpu.IsAppleSilicon())
fmt.Println("pCore GHz", m1cpu.PCoreGHz())
fmt.Println("eCore GHz", m1cpu.ECoreGHz())
fmt.Println("pCore Hz", m1cpu.PCoreHz())
fmt.Println("eCore Hz", m1cpu.ECoreHz())
}
This package requires the use of CGO. Extracting the CPU properties is done via Apple's IOKit framework, which is accessible only through system C libraries.
Open source under the MPL