Start this profiler. Must be run from the thread you intend to profile.
()
| 42 | * Start this profiler. Must be run from the thread you intend to profile. |
| 43 | */ |
| 44 | @Override |
| 45 | public void start() { |
| 46 | samples.clear(); |
| 47 | if (server != null) { |
| 48 | return; |
| 49 | } |
| 50 | server = Thread.currentThread(); |
| 51 | scheduler = Executors.newSingleThreadScheduledExecutor(); |
| 52 | scheduler.scheduleAtFixedRate(() -> { |
| 53 | new Thread(() -> { |
| 54 | if (server == null) { |
| 55 | return; |
| 56 | } |
| 57 | Sample sample = new Sample(server.getStackTrace(), System.currentTimeMillis()); |
| 58 | while (!samples.offer(sample)) { |
| 59 | samples.poll(); |
| 60 | } |
| 61 | }).start(); |
| 62 | }, 1, 1, TimeUnit.MILLISECONDS); |
| 63 | } |
| 64 | |
| 65 | protected void end() { |
| 66 | if (scheduler != null) { |
nothing calls this directly
no test coverage detected