Class TimeMarker

java.lang.Object
org.jppf.utils.TimeMarker

public class TimeMarker extends Object
A simple utility class to measure the elapsed time between two points in the code. Typicaly it is used as follows:
TimeMarker marker = new TimeMarker().start();
 // ... execute some code ...
 long elapsed = marker.stop().getLastElapsed();
 System.out.println("elapsed time: " + marker.getLastElapsedAsString());
Author:
Laurent Cohen
  • Constructor Details

    • TimeMarker

      public TimeMarker()
  • Method Details

    • start

      public TimeMarker start()
      Start a new measurement.
      Returns:
      this TimeMarker.
    • stop

      public TimeMarker stop()
      Stop the current measurement.
      Returns:
      this TimeMarker.
    • markTime

      public TimeMarker markTime()
      Take a measurement and recompute the last and total elapsed times.
      Returns:
      this TimeMarker.
    • getLastElapsed

      public long getLastElapsed()
      Get the elapsed time for the last measurement.
      Returns:
      the elapsed time as a long value.
    • getLastElapsedMillis

      public long getLastElapsedMillis()
      Get the elapsed time for the last measurement in milliseconds.
      Returns:
      the elapsed time as a long value.
    • getTotalElapsed

      public long getTotalElapsed()
      Get the total elapsed time for all measurements in milliseconds.
      Returns:
      the elapsed time as a long value.
    • getTotalElapsedMillis

      public long getTotalElapsedMillis()
      Get the total elapsed time for all measurements.
      Returns:
      the elapsed time as a long value.
    • getLastElapsedAsString

      public String getLastElapsedAsString()
      Get the elapsed time for the last measurement formatted as hh:mm:ss.nnn
      Returns:
      a string representation of the last elapsed time.
    • getTotalElapsedAsString

      public String getTotalElapsedAsString()
      Get the total elapsed time formatted as hh:mm:ss.nnn
      Returns:
      a string representation of the total elapsed time.
    • getCount

      public int getCount()
      Get the count of measurements.
      Returns:
      the count as an int value.