Uses 1113K of libraries. Click here for Pure Java version (13162L/63K).
!7 cm > DynPrintLogAndEnabled { switchable double interval = 1.0; // seconds switchable int numberSize = 20; S aCurrentStackTrace; sclass Entry { long threadID; S threadName; WeakRef<Thread> thread; StackTraceElement[] stackTrace; bool runnable; } transient L<Entry> entries; transient volatile Map<Thread, StackTraceElement[]> stackTraces; // weakHashMap transient volatile Map<Thread, StackTraceElement[]> runnableStackTraces; start { dm_reloadOnFieldChange enabled(); if (enabled) dm_doEvery(interval, r { if (!enabled) ret; var raw = allThreadsWithStackTraces(); raw = mapMinus(raw, currentThread()); setField(entries := map(raw, (t, st) -> { new Entry e; e.threadID = threadID(t); e.threadName = threadName(t); e.thread = weakRef(t); e.stackTrace = st; e.runnable = isThreadRunnable_x(t, st); ret e; })); setField(stackTraces := toWeakHashMap(raw)); setField(runnableStackTraces := mapToWeakHashMap(filter(entries, e -> e.runnable), e -> pair(e.thread!, e.stackTrace))); setModuleName(n2(runnableStackTraces, "runnable thread") + " [Permanent Mini Profiler]"); var rand = random(runnableStackTraces); setField(aCurrentStackTrace := rand == null ?: rand.a + "\n\n" + stackTraceToString(rand.b)); vmBus_send freshStackTraces(stackTraces, weakRef(me())); }); } S renderStats() { ret stackTraces == null ? "" : jlabel_centerHTML(joinWithBR( hfontsize(numberSize, b(n2(runnableStackTraces))), (l(runnableStackTraces) == 1 ? "thread" : "threads") + " running", n2(l(stackTraces)-l(runnableStackTraces)) + " idle")); } visual westAndCenterWithMargins( dm_calculatedCenteredLabel renderStats(), dm_uneditableTextArea aCurrentStackTrace()); // API Map<Thread, StackTraceElement[]> runnableStackTraces() { ret runnableStackTraces; } }
download show line numbers debug dex old transpilations
Travelled to 5 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1031777 | 
| Snippet name: | Permanent Mini Profiler [get all stacktraces once a second] | 
| Eternal ID of this version: | #1031777/26 | 
| Text MD5: | e7fc194626e94daff58c189f75c6a259 | 
| Transpilation MD5: | ab0c69dadd5a6683c99b0db26f9a4f59 | 
| Author: | stefan | 
| Category: | javax | 
| Type: | JavaX source code (Dynamic Module) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2022-03-30 13:35:36 | 
| Source code size: | 2020 bytes / 65 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 440 / 16040 | 
| Version history: | 25 change(s) | 
| Referenced in: | [show references] |