title: Measuring execution time for a Java doesn't work
body: <p>I'm looking for measuring the execution time for a concret method in java. To be more precise I have implemented System.nanoTime() method rather than System.currentTimeMillis():</p>
  
  <pre><code>long startTime = System.nanoTime(); 
  ServerRequestState state = (ServerRequestState) search.getGoalState();
  long endTime = System.nanoTime();               
  long elapsedTime = (endTime - startTime) / 1000000; // time in ms
  </code></pre>
  
  <p>But this has not worked for me, methods running between 30 and 40 seconds later, but the result of the variable elapsedTime says just 4 ms, 1 ms in some cases.</p>
  
  <p>Any ideas why this is not working?</p>