Libraryless. Click here for Pure Java version (4816L/26K).
static new MultiSet<S> poorMansProfiling_results; static int poorMansProfiling_samples; static java.util.Timer poorMansProfiling_timer; static Lock poorMansProfiling_lock = lock(); static Thread poorMansProfiling_threadToSample; // otherwise sample all threads static void poorMansProfiling() { poorMansProfiling(poorMansProfiling_defaultInterval()); } static void poorMansProfiling(Thread thread) { poorMansProfiling(poorMansProfiling_defaultInterval(), thread); } static void poorMansProfiling(int interval) { poorMansProfiling(interval, null); } static void poorMansProfiling(int interval, Thread thread) { lock poorMansProfiling_lock; poorMansProfiling_threadToSample = thread; poorMansProfiling_stop(); poorMansProfiling_clear(); poorMansProfiling_timer = doEvery_daemon(interval, r { Map<Thread, StackTraceElement[]> map = poorMansProfiling_threadToSample != null ? litmap(poorMansProfiling_threadToSample, poorMansProfiling_threadToSample.getStackTrace()) : runnableThreadsWithStackTraces(); lock poorMansProfiling_lock; poorMansProfiling_samples++; for (Thread t : keys(map)) { continue if isSystemThread(t); new StringBuilder buf; for (StackTraceElement e : map.get(t)) buf.append(e).append("\n"); poorMansProfiling_results.add(str(buf)); } }); } static void poorMansProfiling_stop() { lock poorMansProfiling_lock; if (poorMansProfiling_timer != null) { stopTimer(poorMansProfiling_timer); poorMansProfiling_timer = null; } } static void poorMansProfiling_clear() { lock poorMansProfiling_lock; poorMansProfiling_results.clear(); poorMansProfiling_samples = 0; } static MultiSet<S> poorMansProfiling_results() { ret new MultiSet(poorMansProfiling_results); } static MultiSet<S> poorMansProfiling_stopAndGetResults() { lock poorMansProfiling_lock; poorMansProfiling_stop(); ret poorMansProfiling_results(); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1011686 |
Snippet name: | poorMansProfiling |
Eternal ID of this version: | #1011686/20 |
Text MD5: | f429a0a12a23fd4cd97b01acec96458a |
Transpilation MD5: | c7bc6733fd6f526cf4e8c751d19f3b3e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-20 12:21:11 |
Source code size: | 2006 bytes / 63 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 585 / 661 |
Version history: | 19 change(s) |
Referenced in: | [show references] |