D9689: [WIP] Add a per-process CPU usage graph shown in the process list
fvogt updated this revision to Diff 24921. fvogt added a comment. Address review comments. Set a unified alpha for percentage marker and history graph to avoid sudden changes: 33%: Percentage marker 66%: History graph 100%: Text Screenshot is linked in the test plan. REPOSITORY R111 KSysguard Library CHANGES SINCE LAST UPDATE https://phabricator.kde.org/D9689?vs=24838=24921 BRANCH history REVISION DETAIL https://phabricator.kde.org/D9689 AFFECTED FILES processui/ProcessModel.cpp processui/ProcessModel.h processui/ProcessModel_p.h processui/ksysguardprocesslist.cpp tests/processtest.cpp tests/processtest.h To: fvogt, #plasma Cc: broulik, ngraham, plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
D9689: [WIP] Add a per-process CPU usage graph shown in the process list
broulik added a comment. Screenshot? :) INLINE COMMENTS > ProcessModel.cpp:804 > + * didn't change though. */ > +if(mMapProcessCPUHistory.contains(process)) { > +auto = mMapProcessCPUHistory[process]; Use `find()` to avoid double lookup (contains+operator[]) > ProcessModel.cpp:808 > +// Only add an entry if the latest one is older than MIN_HIST_AGE > +if(!history.size() || timestamp - history.constLast().timestamp > > MIN_HIST_AGE) { > +if(history.size() == MAX_HIST_ENTRIES) `isEmpty()` > ProcessModel.cpp:809 > +if(!history.size() || timestamp - history.constLast().timestamp > > MIN_HIST_AGE) { > +if(history.size() == MAX_HIST_ENTRIES) > +history.removeFirst(); Braces also for one-line statements REPOSITORY R111 KSysguard Library REVISION DETAIL https://phabricator.kde.org/D9689 To: fvogt, #plasma Cc: broulik, ngraham, plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
D9689: [WIP] Add a per-process CPU usage graph shown in the process list
fvogt updated this revision to Diff 24838. fvogt added a comment. Forgot to save ProcessModel.cpp before git commit. REPOSITORY R111 KSysguard Library CHANGES SINCE LAST UPDATE https://phabricator.kde.org/D9689?vs=24836=24838 BRANCH history REVISION DETAIL https://phabricator.kde.org/D9689 AFFECTED FILES processui/ProcessModel.cpp processui/ProcessModel.h processui/ProcessModel_p.h processui/ksysguardprocesslist.cpp tests/processtest.cpp tests/processtest.h To: fvogt, #plasma Cc: ngraham, plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
D9689: [WIP] Add a per-process CPU usage graph shown in the process list
fvogt updated this revision to Diff 24836. fvogt added a comment. Instead of updating the last entry's timestamp if the value is the same, add a new entry only if the latest entry has a certain age. Otherwise, the interpolation results would look differently and processes had different lengths of histroy graphs depending on the values, which looks odd. REPOSITORY R111 KSysguard Library CHANGES SINCE LAST UPDATE https://phabricator.kde.org/D9689?vs=24804=24836 BRANCH history REVISION DETAIL https://phabricator.kde.org/D9689 AFFECTED FILES processui/ProcessModel.cpp processui/ProcessModel.h processui/ProcessModel_p.h processui/ksysguardprocesslist.cpp tests/processtest.cpp tests/processtest.h To: fvogt, #plasma Cc: ngraham, plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
D9689: [WIP] Add a per-process CPU usage graph shown in the process list
fvogt updated this revision to Diff 24804. fvogt added a comment. Remove the history tail before appending the head to never exceed the reserved vector size REPOSITORY R111 KSysguard Library CHANGES SINCE LAST UPDATE https://phabricator.kde.org/D9689?vs=24803=24804 BRANCH history REVISION DETAIL https://phabricator.kde.org/D9689 AFFECTED FILES processui/ProcessModel.cpp processui/ProcessModel.h processui/ProcessModel_p.h processui/ksysguardprocesslist.cpp tests/processtest.cpp tests/processtest.h To: fvogt, #plasma Cc: plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
D9689: [WIP] Add a per-process CPU usage graph shown in the process list
fvogt created this revision. fvogt added a reviewer: Plasma. Restricted Application added a project: Plasma. fvogt requested review of this revision. REVISION SUMMARY By adding a new PercentageHistoryRole returning a QVector with timestamps and values, the delegate can show the history of the percentage as background. This is currently only done for the CPU usage, but can easily be added for memory as well. The history vector is only created and filled after the first access on each process. TEST PLAN Added a small testcase which verifies that the history vector has an entry with the current value after the first refresh after the initial access. The end result looks like this: https://phabricator.kde.org/file/data/mwuxhmkgb7p5gr2jl6ax/PHID-FILE-v76g3drarovozb4fue3w/KSysguard_with_per-process_cpu_graph REPOSITORY R111 KSysguard Library BRANCH history REVISION DETAIL https://phabricator.kde.org/D9689 AFFECTED FILES processui/ProcessModel.cpp processui/ProcessModel.h processui/ProcessModel_p.h processui/ksysguardprocesslist.cpp tests/processtest.cpp tests/processtest.h To: fvogt, #plasma Cc: plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart