Transpiled version (11078L) is out of date.
asclass AbstractProfiler is AutoCloseable { // config settable int interval = 40; // 25 Hz settable bool skipSleeping; // results new MultiSet<S> stackTraceMultiSet; gettable volatile int samples; // temporary java.util.Timer timer; Lock lock = lock(); void start { lock lock; assertCanStart(); printWithMS("Starting " + this); stop(); clear(); timer = doEvery_daemon("Profiler", interval, r stepImpl); } void assertCanStart {} abstract void stepImpl(); public void stop aka close() { lock lock; if (timer != null) { stopTimer(timer); timer = null; printWithMS("Stopped " + this); } } void clear() { lock lock; stackTraceMultiSet.clear(); samples = 0; } MultiSet<S> results() { lock lock; ret cloneMultiSet(stackTraceMultiSet); } MultiSet<S> stopAndGetResults() { lock lock; stop(); ret results(); } S renderFullResults(bool mostImportantLast) { var traces = results(); int n = traces.size(); int percent = ratioToIntPercent(l(traces), samples); ret (samples == 0 ? "Nothing sampled" : percent + "% core activity [" + n2(samples, "sample") + " taken]") + "\n\n" + joinMap(mostImportantLast ? traces.lowestFirst() : traces.highestFirst(), trace -> traces.get(trace) + "/" + n + "\n" + trace + "\n\n" ); } // must be locked first protected void addSample(StackTraceElement[] stackTrace) { stackTraceMultiSet.add(stackTraceToString(stackTrace)); } }
Began life as a copy of #1035050
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036378 |
Snippet name: | AbstractProfiler |
Eternal ID of this version: | #1036378/10 |
Text MD5: | 728419c663cf104ae35694525a04a315 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-11-30 11:59:30 |
Source code size: | 1612 bytes / 67 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 139 / 212 |
Version history: | 9 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |