Uses 911K of libraries. Click here for Pure Java version (4853L/25K).
1 | !7 |
2 | |
3 | cmodule SaveStackTracesIfHighCPUUse > DynPrintLogAndEnabled { |
4 | double period = 10.0; |
5 | transient WaitForStableValue<Bool> high; |
6 | |
7 | start { |
8 | high = WaitForStableValue(period); |
9 | doEvery(2.0, r check); |
10 | } |
11 | |
12 | void check enter { |
13 | if (dm_osLoading()) ret; |
14 | int load = iround(dm_processCPUPercentageRelativeToAllCores()); |
15 | high.set(load >= 50); |
16 | if (isTrue(high!)) { |
17 | time { |
18 | S traces = renderAllThreadsWithStackTraces(); |
19 | logQuotedWithDate(javaxDataDir("high-cpu-stack-traces.txt"), traces); |
20 | } |
21 | done_always("CPU load: " + load + "%, saving stack trace"); |
22 | high.set(false); // wait another 10 seconds |
23 | } |
24 | } |
25 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023851 |
Snippet name: | Save Stack Traces If Process CPU use > 50% of all cores for 10 seconds |
Eternal ID of this version: | #1023851/11 |
Text MD5: | c2cf319c083a1a05435a3bf6aa2375d5 |
Transpilation MD5: | 1486bb812d336e66d3ac5bc438b036a4 |
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: | 2019-07-24 13:37:49 |
Source code size: | 692 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 215 / 30293 |
Version history: | 10 change(s) |
Referenced in: | [show references] |