Here's how to get the system CPU frequency in Rust using the cpuid
crate:
main.rs274 chars11 lines
Here, we're using the CpuId
struct from the cpuid
crate to get information about the CPU. The get_processor_frequency_info
method returns an Option
containing a cpuid::frequency::Info
struct, which has the actual and maximum frequencies of the CPU. We're using the actual()
method to get the actual frequency and printing it out.
gistlibby LogSnag