Class StopWatch

java.lang.Object
be.panako.util.StopWatch

public final class StopWatch extends Object
StopWatch counts the ticks (ns) passed between initialization and invocation of ticksPassed.
  • Constructor Details

    • StopWatch

      public StopWatch()
      Create and start the stop watch.
  • Method Details

    • ticksPassed

      public long ticksPassed()
      Returns:
      The number of ticks passed between initialization and the call to ticksPassed. In milliseconds or 10^-3 seconds.
    • nanoTicksPassed

      public long nanoTicksPassed()
      Returns:
      The number of ticks passed between initialization and the call to ticksPassed. In nanoseconds or 10^-9 seconds.
    • timePassed

      public double timePassed(TimeUnit unit)
      Calculates and returns the time passed in the requested unit.
      Parameters:
      unit - The requested time unit.
      Returns:
      The time passed in the requested unit.
    • start

      public void start()
      Starts or restarts the watch.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toTime

      public static String toTime(String inputResource, int currentSeconds)
      Returns a 24h time string based on an input resource. E.g. "20120325-235950" + 25 seconds would return "00:00:15"
      Parameters:
      inputResource - The name of the input resource with a date and time part. E.g. "20120325-235950.wav"
      currentSeconds - The number of seconds to add to the time part.
      Returns:
      E.g. "20120325-235950" + 25 seconds would return "00:00:15"
    • formattedToString

      public String formattedToString()
    • formattedToString

      public static String formattedToString(double secondsPassed)