-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
Add governor information #1057
Open
patrickelectric
wants to merge
8
commits into
GuillaumeGomez:master
Choose a base branch
from
patrickelectric:governor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add governor information #1057
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
29f7eee
examples: simple: Add governor command
patrickelectric eae2acf
src: common: Add GovernorKind
patrickelectric 5645eca
src: debug: Add governor for Cpu
patrickelectric 16913bf
src: linux: cpu: Add governor function
patrickelectric 09e3fa6
src: traits: Add governor function for CpuExt
patrickelectric 8678bcd
src: lib: Add GovernorKind
patrickelectric 3b1428b
src: linux: system: Add governor function
patrickelectric 6b48f22
src: {apple,freebsd,unknown,windows}: Add governor function for Syste…
patrickelectric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ use crate::{ | |
sys::{Component, Cpu, Disk, Process}, | ||
}; | ||
use crate::{ | ||
CpuRefreshKind, DiskKind, DiskUsage, Disks, Group, LoadAvg, Networks, NetworksIter, Pid, | ||
ProcessRefreshKind, ProcessStatus, RefreshKind, Signal, User, | ||
CpuRefreshKind, DiskKind, DiskUsage, Disks, GovernorKind, Group, LoadAvg, Networks, | ||
NetworksIter, Pid, ProcessRefreshKind, ProcessStatus, RefreshKind, Signal, User, | ||
}; | ||
|
||
use std::collections::HashMap; | ||
|
@@ -570,6 +570,20 @@ pub trait CpuExt: Debug { | |
/// } | ||
/// ``` | ||
fn frequency(&self) -> u64; | ||
|
||
/// Returns the CPU's governor. | ||
/// | ||
/// ```no_run | ||
/// use sysinfo::{CpuExt, GovernorKind, System, SystemExt, RefreshKind, CpuRefreshKind}; | ||
/// | ||
/// let s = System::new_with_specifics( | ||
/// RefreshKind::new().with_cpu(CpuRefreshKind::everything()), | ||
/// ); | ||
/// for cpu in s.cpus() { | ||
/// println!("{}", cpu.governor()); | ||
/// } | ||
/// ``` | ||
fn governor(&self) -> GovernorKind; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should return an |
||
} | ||
|
||
/// Contains all the methods of the [`System`][crate::System] type. | ||
|
@@ -1069,6 +1083,18 @@ pub trait SystemExt: Sized + Debug + Default + Send + Sync { | |
/// ``` | ||
fn global_cpu_info(&self) -> &Cpu; | ||
|
||
/// Returns the CPUs governor being used. | ||
/// | ||
/// ```no_run | ||
/// use sysinfo::{CpuRefreshKind, CpuExt, RefreshKind, System, SystemExt}; | ||
/// | ||
/// let s = System::new_with_specifics( | ||
/// RefreshKind::new().with_cpu(CpuRefreshKind::everything()), | ||
/// ); | ||
/// println!("{}%", s.global_cpu_info().cpu_usage()); | ||
/// ``` | ||
fn governor(&self) -> GovernorKind; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this from |
||
|
||
/// Returns the list of the CPUs. | ||
/// | ||
/// By default, the list of CPUs is empty until you call [`SystemExt::refresh_cpu`] or | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not displaying this information as part of the CPUs directly?