Class Timer

java.lang.Object
com.norconex.commons.lang.time.Timer

public final class Timer extends Object
Time the execution of arbitrary code and return the elapsed time.
Since:
3.0.0
  • Method Details

    • time

      public static long time(Runnable runnable)
      Returns the runnable execution time in milliseconds.
      Parameters:
      runnable - the code to execute
      Returns:
      elapsed time in milliseconds
    • timeDuration

      public static Duration timeDuration(Runnable runnable)
      Returns the runnable execution time as a Duration.
      Parameters:
      runnable - the code to execute
      Returns:
      elapsed time as Duration
    • timeWatch

      public static StopWatch timeWatch(Runnable runnable)
      Returns the runnable execution time as a stopped StopWatch.
      Parameters:
      runnable - the code to execute
      Returns:
      elapsed time as a stopped StopWatch