mirror of
https://github.com/danbulant/nushell
synced 2026-05-19 12:29:03 +00:00
Remove unnecessary work from ps (#3407)
The ps plugin has an unnecessary call to `std:🧵:sleep(500ms)` that delays runtime by 500ms. Additionally, there is a call to `sysinfo::SystemExt::refresh_process`, which is not required as the previous call to sysinfo::SystemExt::refresh_all handles the "refresh" of all processes without a need to do this individually. Combining both of these improvements means that running ps runs nearly instentaneously. Fixes #3402
This commit is contained in:
parent
48128c9db6
commit
b93b80ccaa
1 changed files with 0 additions and 3 deletions
|
|
@ -15,15 +15,12 @@ impl Ps {
|
|||
pub async fn ps(tag: Tag, long: bool) -> Result<Vec<Value>, ShellError> {
|
||||
let mut sys = System::new_all();
|
||||
sys.refresh_all();
|
||||
let duration = std::time::Duration::from_millis(500);
|
||||
std::thread::sleep(duration);
|
||||
|
||||
let mut output = vec![];
|
||||
|
||||
let result: Vec<_> = sys.get_processes().iter().map(|x| *x.0).collect();
|
||||
|
||||
for pid in result.into_iter() {
|
||||
sys.refresh_process(pid);
|
||||
if let Some(result) = sys.get_process(pid) {
|
||||
let mut dict = TaggedDictBuilder::new(&tag);
|
||||
dict.insert_untagged("pid", UntaggedValue::int(pid));
|
||||
|
|
|
|||
Loading…
Reference in a new issue