mirror of https://github.com/aristocratos/btop.git
Small optimization for collect
This commit is contained in:
parent
f3628a96eb
commit
b4d223cf40
|
@ -622,11 +622,11 @@ int main(int argc, char **argv){
|
|||
|
||||
|
||||
if (rcount > 0) avgtimes.push_front(timestamp);
|
||||
if (avgtimes.size() > 10) avgtimes.pop_back();
|
||||
if (avgtimes.size() > 100) avgtimes.pop_back();
|
||||
cout << pbox << ostring << Fx::reset << "\n" << endl;
|
||||
cout << Mv::to(Term::height - 4, 1) << "Processes call took: " << rjust(to_string(timestamp), 5) << " μs. Average: " <<
|
||||
rjust(to_string(accumulate(avgtimes.begin(), avgtimes.end(), 0) / avgtimes.size()), 5) << " μs of " << avgtimes.size() <<
|
||||
" samples. Drawing took: " << time_micros() - timestamp2 << " μs.\nNumber of processes: " << Proc::numpids << ". Run count: " <<
|
||||
" samples. Drawing took: " << time_micros() - timestamp2 << " μs.\nNumber of processes: " << Proc::numpids << ". Number in vector: " << plist.size() << ". Run count: " <<
|
||||
++rcount << ". Time: " << strf_time("%X ") << endl;
|
||||
|
||||
while (time_ms() < tsl) {
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace Proc {
|
|||
}
|
||||
}
|
||||
pread.close();
|
||||
user = (not uid.empty() and uid_user.contains(uid)) ? uid_user.at(uid) : uid;
|
||||
user = (uid_user.contains(uid)) ? uid_user.at(uid) : uid;
|
||||
}
|
||||
else continue;
|
||||
cache[new_proc.pid] = {name, cmd, user};
|
||||
|
@ -241,14 +241,14 @@ namespace Proc {
|
|||
string instr;
|
||||
getline(pread, instr);
|
||||
pread.close();
|
||||
size_t s_pos = 0, c_pos = 0, s_count = 0;
|
||||
size_t c_pos = 0, s_count = 0;
|
||||
uint64_t cpu_t = 0;
|
||||
|
||||
//? Skip pid and comm field and find comm fields closing ')'
|
||||
s_pos = instr.find_last_of(')') + 2;
|
||||
if (s_pos == string::npos) continue;
|
||||
|
||||
try {
|
||||
//? Skip pid and comm field and find comm fields closing ')'
|
||||
size_t s_pos = pid_str.size() + cache.at(new_proc.pid).name.size() + 4;
|
||||
if (instr.at(s_pos - 2) != ')')
|
||||
s_pos = instr.find_last_of(')') + 2;
|
||||
do {
|
||||
c_pos = instr.find(' ', s_pos);
|
||||
if (c_pos == string::npos) break;
|
||||
|
@ -291,7 +291,7 @@ namespace Proc {
|
|||
s_pos = c_pos + 1;
|
||||
} while (s_count++ < 36);
|
||||
}
|
||||
catch (std::out_of_range&) {
|
||||
catch (...) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue