Giter Club home page Giter Club logo

go-m1cpu's Introduction

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 M1 and M2 CPUs.

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 M1/M2 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

go-m1cpu's People

Contributors

shoenig avatar zhongruoyu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.