Uses 6517K of libraries. Click here for Pure Java version (9427L/48K).
!7 sclass Process { S processID, name, commandLine; long residentSize; double cpuUsage; // percent per core sS _fieldOrder = "processID name commandLine residentSize cpuUsage"; } cm ProcessList > DynObjectTable<Process> { switchable bool showTiming; switchable double interval = 3.0; switchable double firstInterval = 1.0; switchable bool sortBySize; start { dontPersist(); itemToMap = func(Process p) -> Map { humanizeKeys( applyFunctionToMapValue('cpuUsage, f iround_spacePercentSign, applyFunctionToMapValue('residentSize, f str_toM, objectToMap_honorFieldOrder(p)))) }; actualUpdate(); // to make sort keys work dm_doEvery(firstInterval, interval, r actualUpdate); dm_reloadOnFieldChange interval(); dm_reloadOnFieldChange sortBySize(); } visualize { JComponent c = centerAndSouthWithMargins(jSection( dm_liveValue(() -> nProcesses(count())), super.visualize()), dm_calculatedRightAlignedLabel(() -> "Updated every " + (interval == 1 ? "second" : formatDouble(interval, 1) + " seconds"))); addRowSorter_desc(table, sortBySize ? 3 : 4); // Resident Size / CPU var cmp = alphaNumComparator_skipCommas(); rowSorter_setComparators(table, 3, cmp, 2, cmp, 4, cmp); swing { ((DefaultRowSorter) table.getRowSorter()).sort(); } tablePopupMenuItem(table(), "Kill!", rThread { killProcess(selected().processID) }); ret c; } void actualUpdate enter { L<OSProcess> list = timedIf(showTiming, func -> L<OSProcess> { oshi_listProcesses_withoutOpenFiles() }); setData(map(list, func(OSProcess p) -> Process { nu(Process, processID := str(p.getProcessID()), name := p.getName(), commandLine := p.getCommandLine(), residentSize := p.getResidentSetSize(), cpuUsage := oshi_calcProcessCPUUsage_v2(p)) })); } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019486 |
Snippet name: | Process List [Dyn Module] |
Eternal ID of this version: | #1019486/56 |
Text MD5: | 83abd089a4aa62a61fe11d0029f8c903 |
Transpilation MD5: | 7da9130f746c07d1a1a606d101abc6aa |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-14 09:09:05 |
Source code size: | 1946 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 479 / 173027 |
Version history: | 55 change(s) |
Referenced in: | [show references] |