m1cpu

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2023 License: MPL-2.0 Imports: 0 Imported by: 2

README

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 library for looking up the CPU frequency for Apple M1 and M2 CPUs.

Install

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

Example

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

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.

License

Open source under the MPL

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ECoreGHz

func ECoreGHz() float64

ECoreGHz returns the max frequency in Gigahertz of the E-Core of an Apple Silicon CPU.

func ECoreHz

func ECoreHz() uint64

ECoreHZ returns the max frequency in Hertz of the E-Core of an Apple Silicon CPU.

func IsAppleSilicon

func IsAppleSilicon() bool

IsAppleSilicon return false on this platform.

func PCoreGHz

func PCoreGHz() float64

PCoreGHz returns the max frequency in Gigahertz of the P-Core of an Apple Silicon CPU.

func PCoreHz

func PCoreHz() uint64

PCoreHZ returns the max frequency in Hertz of the P-Core of an Apple Silicon CPU.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL