/** * Start the timer. */ public synchronized void start() { if ((todoFlags & RECORD_CPUTIME) != 0) { currentStartCpuTime = getThreadCpuTime(threadId); } else { currentStartCpuTime = -1; } if ((todoFlags & RECORD_WALLTIME) != 0) { currentStartWallTime = System.nanoTime(); } else { currentStartWallTime = -1; } isRunning = true; }
/** * Start the timer. */ public synchronized void start() { if ((todoFlags & RECORD_CPUTIME) != 0) { currentStartCpuTime = getThreadCpuTime(threadId); } else { currentStartCpuTime = -1; } if ((todoFlags & RECORD_WALLTIME) != 0) { currentStartWallTime = System.nanoTime(); } else { currentStartWallTime = -1; } isRunning = true; }
/** * Start the timer. */ public synchronized void start() { if ((todoFlags & RECORD_CPUTIME) != 0) { currentStartCpuTime = getThreadCpuTime(threadId); } else { currentStartCpuTime = -1; } if ((todoFlags & RECORD_WALLTIME) != 0) { currentStartWallTime = System.nanoTime(); } else { currentStartWallTime = -1; } isRunning = true; }
/** * Start the timer. */ public synchronized void start() { if ((todoFlags & RECORD_CPUTIME) != 0) { currentStartCpuTime = getThreadCpuTime(threadId); } else { currentStartCpuTime = -1; } if ((todoFlags & RECORD_WALLTIME) != 0) { currentStartWallTime = System.nanoTime(); } else { currentStartWallTime = -1; } isRunning = true; }
/** * Stop the timer and return the CPU time that has passed since it had last * been started. The total time (both system and CPU) of all start-stop * cycles is recorded with the timer. * * @return CPU time that the timer was running, or -1 if timer not running * or CPU time unavailable for other reasons */ public synchronized long stop() { long totalTime = -1; if ((todoFlags & RECORD_CPUTIME) != 0 && (currentStartCpuTime != -1)) { long cpuTime = getThreadCpuTime(threadId); if (cpuTime != -1) { // may fail if thread already dead totalTime = cpuTime - currentStartCpuTime; totalCpuTime += totalTime; } } if ((todoFlags & RECORD_WALLTIME) != 0 && (currentStartWallTime != -1)) { long wallTime = System.nanoTime(); totalWallTime += wallTime - currentStartWallTime; } if (isRunning) { measurements += 1; isRunning = false; } currentStartWallTime = -1; currentStartCpuTime = -1; return totalTime; }
/** * Stop the timer and return the CPU time that has passed since it had last * been started. The total time (both system and CPU) of all start-stop * cycles is recorded with the timer. * * @return CPU time that the timer was running, or -1 if timer not running * or CPU time unavailable for other reasons */ public synchronized long stop() { long totalTime = -1; if ((todoFlags & RECORD_CPUTIME) != 0 && (currentStartCpuTime != -1)) { long cpuTime = getThreadCpuTime(threadId); if (cpuTime != -1) { // may fail if thread already dead totalTime = cpuTime - currentStartCpuTime; totalCpuTime += totalTime; } } if ((todoFlags & RECORD_WALLTIME) != 0 && (currentStartWallTime != -1)) { long wallTime = System.nanoTime(); totalWallTime += wallTime - currentStartWallTime; } if (isRunning) { measurements += 1; isRunning = false; } currentStartWallTime = -1; currentStartCpuTime = -1; return totalTime; }
/** * Stop the timer and return the CPU time that has passed since it had last * been started. The total time (both system and CPU) of all start-stop * cycles is recorded with the timer. * * @return CPU time that the timer was running, or -1 if timer not running * or CPU time unavailable for other reasons */ public synchronized long stop() { long totalTime = -1; if ((todoFlags & RECORD_CPUTIME) != 0 && (currentStartCpuTime != -1)) { long cpuTime = getThreadCpuTime(threadId); if (cpuTime != -1) { // may fail if thread already dead totalTime = cpuTime - currentStartCpuTime; totalCpuTime += totalTime; } } if ((todoFlags & RECORD_WALLTIME) != 0 && (currentStartWallTime != -1)) { long wallTime = System.nanoTime(); totalWallTime += wallTime - currentStartWallTime; } if (isRunning) { measurements += 1; isRunning = false; } currentStartWallTime = -1; currentStartCpuTime = -1; return totalTime; }
/** * Stop the timer and return the CPU time that has passed since it had last * been started. The total time (both system and CPU) of all start-stop * cycles is recorded with the timer. * * @return CPU time that the timer was running, or -1 if timer not running * or CPU time unavailable for other reasons */ public synchronized long stop() { long totalTime = -1; if ((todoFlags & RECORD_CPUTIME) != 0 && (currentStartCpuTime != -1)) { long cpuTime = getThreadCpuTime(threadId); if (cpuTime != -1) { // may fail if thread already dead totalTime = cpuTime - currentStartCpuTime; totalCpuTime += totalTime; } } if ((todoFlags & RECORD_WALLTIME) != 0 && (currentStartWallTime != -1)) { long wallTime = System.nanoTime(); totalWallTime += wallTime - currentStartWallTime; } if (isRunning) { measurements += 1; isRunning = false; } currentStartWallTime = -1; currentStartCpuTime = -1; return totalTime; }