Clone this repo:
  1. 84ae9f2 build(deps): bump actions/setup-go from 6 to 7 (#35) by dependabot[bot] · 8 days ago main
  2. 8061c5b fix handling of M5 Pro and Max handling (#37) by Michael Schurter · 8 days ago v0.2.4
  3. bcd263c fix: parse the chip generation so M4 and later report Hz (#36) by Igor Churmeev · 13 days ago v0.2.3
  4. 15518bc build(deps): bump actions/checkout from 6 to 7 (#34) by dependabot[bot] · 4 months ago
  5. 49d2af9 ci: modernize repo to use justfile (#33) by Seth Hoenig · 4 months ago

m1cpu

Go Reference MPL License Run CI Tests

The go-m1cpu module is a library for inspecting Apple Silicon CPUs in Go.

Use the m1cpu Go package for looking up the CPU frequency for Apple Silicon M-series CPUs, M1 and later.

Install

go get github.com/shoenig/go-m1cpu@latest

CGO

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.

Example

Simple Go program to print Apple Silicon CPU speeds.

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())
}

Using go test to print out available information.

➜ go test -v -run Show
=== RUN   Test_Show
    cpu_test.go:42: pCore Hz 3504000000
    cpu_test.go:43: eCore Hz 2424000000
    cpu_test.go:44: pCore GHz 3.504
    cpu_test.go:45: eCore GHz 2.424
    cpu_test.go:46: pCore count 8
    cpu_test.go:47: eCoreCount 4
    cpu_test.go:50: pCore Caches 196608 131072 16777216
    cpu_test.go:53: eCore Caches 131072 65536 4194304
--- PASS: Test_Show (0.00s)

License

Open source under the MPL