/** * This method returns total CPU time in nanoseconds used since the start of this activity. If the activity has * stopped the value returned is an elapsed CPU time since between activity start/stop calls. If the activity has * not stopped yet, the value is the current used CPU time since the start until now. * * @param ctx * thread context * @return total used CPU time in nanoseconds */ protected static long getUsedCpuTimeNanos(ThreadContext ctx) { if (ctx.stopCPUTime > 0) { return (ctx.stopCPUTime - ctx.startCPUTime); } else if (ctx.startCPUTime > 0) { return (getCurrentCpuTimeNanos(ctx) - ctx.startCPUTime); } else { return -1; } } }
protected void end() { if (!ended) { ended = true; long start = System.nanoTime(); if (startCPUTime > 0) { if (DefaultActivityListener.contTimingSupported) { stopBlockTime = ownerThread.getBlockedTime(); stopWaitTime = ownerThread.getWaitedTime(); } stopCPUTime = DefaultActivityListener.getCurrentCpuTimeNanos(this); } stopBlockCount = ownerThread.getBlockedCount(); stopWaitCount = ownerThread.getWaitedCount(); overHeadTimeNano += (System.nanoTime() - start); } } }