Copyright | (c) Daniel Taskoff 2020 |
---|---|
License | MIT |
Maintainer | daniel.taskoff@gmail.com |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
System.LibCPUID
Description
Bindings to https://github.com/anrieff/libcpuid.
Currently implemented:
- getting CPU vendor and brand strings, TSC availability, number of physical, and logical cores
- measuring CPU clock frequency using a time-stamp counter and time intervals
- getting CPU clock frequency as reported by the OS
- measuring CPU clock frequency using a busy-wait cycle
Synopsis
- getTotalLogicalCores :: IO Int
- clockByOS :: IO Int
- clockMeasure :: Int -> ShouldQuadCheck -> IO Int
- newtype ShouldQuadCheck = ShouldQuadCheck Bool
- clock :: IO Int
- data CPUID = CPUID {
- vendorString :: String
- brandString :: String
- hasTSC :: Bool
- physicalCores :: Int
- logicalCores :: Int
- totalLogicalCores :: Int
- cpuid :: IO (Either String CPUID)
- data TSCMark
- initialise :: IO TSCMark
- mark :: TSCMark -> IO ()
- unmark :: TSCMark -> IO ()
- clockBy :: TSCMark -> IO Int
LibCPUID utilities
getTotalLogicalCores :: IO Int Source #
Get the total number of logical cores (even if CPUID is not present). If CPUID is present, the following is true:
Get the CPU clock frequency in MHz, as reported by the OS (which may differ from the true clock). If the OS is not supported, the result will be -1.
clockMeasure :: Int -> ShouldQuadCheck -> IO Int Source #
Get the CPU clock frequency in MHz, after performing a busy-wait cycle for the given time in ms. If RDTSC is not supported, the result will be -1.
newtype ShouldQuadCheck Source #
Should clockMeasure
do a more thorough measurement (quadruple checking).
Constructors
ShouldQuadCheck Bool |
Get the CPU clock frequency in MHz, by trying all available methods. If all of them fail, the result will be -1.
Reexports from System.LibCPUID.CPUID
CPU information and features.
Constructors
CPUID | |
Fields
|
cpuid :: IO (Either String CPUID) Source #
Get CPU information and features, or an error message, if the CPU can't be identified by libcpuid.