Closed NickLaMuro closed 6 years ago
@NickLaMuro Any chance you could update this for 1.2.x?
Yeah, I can take a look at doing this tomorrow, as well as seeing what it would take for the other operating systems.
@djberg96 Sorry for taking forever to get around to this. I spent a few minutes on this and I think I rebased it properly. That said, I really need to check to be sure, and not sure if the tests cover all cases.
So... benchmarks are not really showing much of a change with this (if anything, this is making it slower...), so unsure whether it is worth the effort. Will leave it up to you.
@NickLaMuro Alright, then I will go ahead and close it.
Changes:
.ps
methodSys::ProcTable.ps
to be a ternary that choose between two helper methods.The new flow of this ternary in
Sys::ProcTable.ps
can be described as follows:pid
passed in, it will callget_info_for_pid
, with thepid
as the argument (and a block, if there is one)pid
value isnil
, then theget_info_for_all_pids
method will be called, andget_info_for_pid
will be called for eachpid
that it finds. Block evaluation is the same as it was before, and running with a block won't add the struct to the array.That said, the changes here have a very minimal impact to performance, if any.
Extracted from https://github.com/djberg96/sys-proctable/pull/65