How can i use Stopwatch [ apache ] to calculate the time taken by a method?
- by Rakesh Juyal
I am using StopWatch [ apache ] to get the time taken by my method. The approach i am following is
StopWatch stopWatch = new StopWatch();
stopWatch.start();
myMethod();
stopWatch.stop();
logger.info( "Time taken by myMethod: " + stopWatch.getTime() + " millisecs");
stopWatch.reset();
stopWatch.start();
anotherMethod();
stopWatch.stop();
logger.info( "Time taken by anotherMethod: " + stopWatch.getTime() + " millisecs");
Thats the only thing i know about StopWatch :).
How/when to use split(), unsplit(), getSplitTime(),suspend()... ?