Conversation
Also avoid potential divide-by-zero in the catch block.
|
The harmonic mean was proposed here: #336 |
Hi @stsdc yes I see that issue was due to older code simply taking the max speed of the core with the highest speed and not averaging all the speedds, hence the issue reported as showing the max turbo of that person's CPU. This PR uses simple average instead of harmonic mean because it appears to be closer to other tools like the Also, avoids a potential divide-by-zero crash here: https://github.com/elementary/monitor/pull/546/changes#diff-0581d222df89dbc56e8440881a1559dbd77f83589c29aed3968cdb0f5b769f34L156 Looks like a worthwhile change, what do you think? |
|
I think you need to ask yourself what are you trying to convey by this number? The average calculated as here is equivalent to answering the question "If all the cpus where running at the same frequency, what frequency would give the same current overall work rate?". This ignores the fact that some cpu cycles that are wasted of course. The harmonic average answers (as an intermediate step) the question "what is the average length of time each processor takes to do the same amount of work?" which, in my opinion, does not make sense if some cpus are not working and leads to possible division by zero. You could fix this by ignoring cpus that are not working. You could also ask "if a single cpu were running all the cpu cycles how fast would it be running?" but the result might mislead. |
|
@jeremypw of course this PR is to tweak the cpu frequency (hertz speed) displayed - there is also the existing untouched cpu utilisation (percentage usage) for each core. example scenario(s) - you might have a heavy single-threaded app which uses just one core to its fullest, so the existing utilisation will show 100% on one core while the others might be near-zero regardless of the core frequency which can differ (say 2 Ghz or 5 Ghz) for the same cpu/computer based on whether the user has configured their computer BIOS/OS to run the cpu on low-power/efficient mode, balanced or performance/overclocked mode, if you see what i'm trying to convey? @stsdc was my explanation about this PR clear enough, about that issue report you linked? |
Simplify and also avoid potential divide-by-zero in the catch block.