0

I want to measure time (like stopwatch) of some code, what I did so far is :

TimeWatch watch = new TimeWatch();
watch = TimeWatch.start();
some code
double passedTimeInSeconds = (watch.time(TimeUnit.MILLISECONDS)) / 1000.0;

does these is the best option and the correct option to calculate the times?

ness
  • 75
  • 7
  • 2
    Does this answer your question? [How do I time a method's execution in Java?](https://stackoverflow.com/questions/180158/how-do-i-time-a-methods-execution-in-java) – MarkusAnd Sep 02 '21 at 20:31
  • does each time I call the start method its start from zero to count the time? `import com.google.common.base.Stopwatch; Stopwatch timer = Stopwatch.createStarted(); //method invocation LOG.info("Method took: " + timer.stop());` – ness Sep 02 '21 at 20:43

0 Answers0