cpu package provides functions to retrieve CPU-related information including times spent in different modes, CPU information, core counts, and utilization percentages.
Import
Functions
Times
Get CPU time statistics for different execution modes
Info
Retrieve detailed CPU hardware information
Counts
Get the number of physical or logical CPU cores
Percent
Calculate CPU utilization percentage
Data Structures
TimesStat
Represents the amount of time the CPU has spent performing different types of work. All time values are in seconds.InfoStat
Contains detailed information about a CPU core.Quick Start
Platform Support
All functions work across multiple platforms:- Linux
- Windows
- macOS (Darwin)
- FreeBSD
- OpenBSD
- NetBSD
- DragonFly BSD
- Solaris
- AIX
- Plan 9