workhorsy / py-cpuinfo

A module for getting CPU info with pure Python
MIT License
310 stars 59 forks source link

Use a much shorter time to measure current cpu frequency #210

Open maxnoe opened 8 months ago

maxnoe commented 8 months ago

This is a simple attempt to fix #205.

The full fix (introducing an API that allows only parts of the cpu info to be read out) would still be appreciated, but this is a simple 100x performance improvement.

The obtained cpu frequencies are still very close to the ones measured with a time of 1.0 seconds (at least on my machine) and since the current cpu freq is anyway time dependent, I think this is as precise as anyone can expect.

anttimc commented 6 months ago

Good idea! For gigahertz frequency there should be still around 10^7 ticks in 0.01 seconds which is plenty. I hope this gets merged soon :+1: