Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: CPU frequency unit in header was MHz, now fixed to GHz #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/processor/processorHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,15 @@ export default GObject.registerClass(
if(this.frequencyMode === 'average') {
const sum = frequency.reduce((a, b) => a + b, 0);
this.frequency.text = Utils.formatFrequency(
sum / frequency.length / 1000,
'MHz',
sum / frequency.length / 1000, /** Convert to GHz */
'GHz',
figures,
true
);
} else if(this.frequencyMode === 'max') {
this.frequency.text = Utils.formatFrequency(
Math.max(...frequency) / 1000,
'MHz',
Math.max(...frequency) / 1000, /** Convert to GHz */
'GHz',
figures,
true
);
Expand Down
8 changes: 8 additions & 0 deletions src/processor/processorMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,14 @@ export default class ProcessorMonitor extends Monitor {
};
}

/**
* Reading frequency from /sys/devices/system/cpu/cpu<N>/cpufreq/scaling_cur_freq
* This read frequency in KHz. This function read the frequency and converts it in MHz
* by dividing it with 1000.
*
* source: https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt#:~:text=scaling_cur_freq%20%3A%20Current%20frequency%20of%20the,and%20cpufreq%20core%2C%20in%20KHz.
*
*/
async updateCpuCoresFrequencyProc(): Promise<boolean> {
if(this.isListeningFor('cpuCoresFrequency')) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ export default class Utils {
return id;
}
}
if(disks.size > 0) return disks.keys().next().value;
if(disks.size > 0) return disks.keys().next().value || null;
return null;
}

Expand Down