If you want to time a segment of code you may do the following. Instantiating Timer is equivalent to Timer.start(). Timer t = new Timer(); String val = searchForStuff(); System.out.println("It took " ...