Option_1: code level
In the business logic code; at the beginning of the start () API call and at the end of the stop () call block. So you get processor time to execute your logic on the current thread. Then write it down. Link
class CPUTimer { private long _startTime = 0l; public void start () { _startTime = getCpuTimeInMillis(); } public long stop () { long result = (getCpuTimeInMillis() - _startTime); _startTime = 0l; return result; } public boolean isRunning () { return _startTime != 0l; } private long getCpuTimeInMillis () { ThreadMXBean bean = ManagementFactory.getThreadMXBean(); return bean.isCurrentThreadCpuTimeSupported() ? bean.getCurrentThreadCpuTime()/1000000: 0L; } }
Option_2: monitor level with plugins (IBM AIX box that does not have jvisualvm support)
If you think this is a delay with adding code now, you might prefer JConsole with plugin support. I followed this article. Download the jar of topthreads from this article and run ./jconsole -pluginpath topthreads-1.1.jar
Option_3: monitor level using TOP (shift H) + JSTACK (Unix machine supporting Shif + H)
Follow this tutorial where the top command will give you the opportunity to find the top CPU thread (nid). Take that check that nid in the jstack output file.
Kanagavelu Sugumar Feb 09 '15 at 11:43 2015-02-09 11:43
source share